]> source.dussan.org Git - gitea.git/log
gitea.git
19 months agoadd margin top to the top of branches (#23002)
HesterG [Tue, 21 Feb 2023 05:03:44 +0000 (13:03 +0800)]
add margin top to the top of branches (#23002)

add margin top as mentioned in #22973

---------

Co-authored-by: jidi <jidi@jidideMacBook-Pro.local>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoAdd me to maintainers (#23026)
yp05327 [Tue, 21 Feb 2023 02:56:13 +0000 (11:56 +0900)]
Add me to maintainers (#23026)

Add me to maintainers.

[My PRs
list](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3Ayp05327+is%3Amerged+)

19 months agoRender access log template as text instead of HTML (#23013)
Lunny Xiao [Tue, 21 Feb 2023 02:22:13 +0000 (10:22 +0800)]
Render access log template as text instead of HTML (#23013)

Fix https://github.com/go-gitea/gitea/pull/22906#discussion_r1112106675

19 months agoUse `gt-relative` class instead of the ambiguous `gt-pr` class (#23008)
wxiaoguang [Tue, 21 Feb 2023 00:16:56 +0000 (08:16 +0800)]
Use `gt-relative` class instead of the ambiguous `gt-pr` class  (#23008)

`.gt-relative` is also `position: relative !important;`

There are `gt-pr-?` styles below (line 140) for `padding-right`, which
makes `.gt-pr` ambiguous

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoFix intermittent panic in notify issue change content (#23019)
zeripath [Tue, 21 Feb 2023 00:15:49 +0000 (00:15 +0000)]
Fix intermittent panic in notify issue change content (#23019)

Ensure that issue pullrequests are loaded before trying to set the
self-reference.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoImprove pull_request_template.md (#22888)
Jason Song [Tue, 21 Feb 2023 00:14:02 +0000 (08:14 +0800)]
Improve pull_request_template.md (#22888)

Update `pull_request_template.md` because:

- It's a kind idea to hide the tips. However, it's easier to include
them in the commit message by mistake when you cannot see them. Check
`git log | grep 'Please check the following:'`. So don't hide it, expose
it and help fix it.
- "for backports" is much clearer than "for bug fixes". I saw someone
post a PR to a release branch because they believed it was the right way
for a bugfix.
- "Allow edits by maintainers", or we have to ask the contributor to
update the branch and they could be confused.
- Remind the contributor that the words could be included in the commit
message, to avoid some words like "Hello", "Sorry". If they really need
them, they can separate them with a line, like:

```markdown
Close #xxxx
Because ... Then ... Finally ...
---
Hello, this is my first time opening a pull request. Sorry for any mistakes.
```
And the merger should be careful, check and delete the extra content
before merging.

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoHide 2FA status from other members in organization members list (#22999)
Brecht Van Lommel [Mon, 20 Feb 2023 23:16:29 +0000 (00:16 +0100)]
Hide 2FA status from other members in organization members list (#22999)

This is rather private information that should not be given to all
members in the same organization. Only show it to organization owners.

19 months agohandle deprecated settings (#22992)
Lunny Xiao [Mon, 20 Feb 2023 22:18:26 +0000 (06:18 +0800)]
handle deprecated settings (#22992)

Fix #22736

19 months agoAdd scopes to API to create token and display them (#22989)
zeripath [Mon, 20 Feb 2023 21:28:44 +0000 (21:28 +0000)]
Add scopes to API to create token and display them (#22989)

The API to create tokens is missing the ability to set the required
scopes for tokens, and to show them on the API and on the UI.

This PR adds this functionality.

Signed-off-by: Andrew Thornton <art27@cantab.net>
19 months agoRemove unnecessary and incorrect `find('.menu').toggle()` (#22987)
wxiaoguang [Mon, 20 Feb 2023 20:44:32 +0000 (04:44 +0800)]
Remove unnecessary and incorrect `find('.menu').toggle()` (#22987)

Follows:
* #22950

The dropdown menu works well without these codes.

The reason is that the event bubbling still works for the dropdown menu,
the Fomantic UI dropdown menu module will hide the menu correctly if an
item is clicked.

19 months agoImprove issues.LoadProject (#22982)
yp05327 [Mon, 20 Feb 2023 19:21:56 +0000 (04:21 +0900)]
Improve issues.LoadProject (#22982)

issues.LoadProject() is no use
change `issues.loadProject(ctx)` to issues.LoadProject(ctx)

19 months agoAdd 1.18.4 changelog (#22991) (#22995)
Lunny Xiao [Mon, 20 Feb 2023 18:09:02 +0000 (02:09 +0800)]
Add 1.18.4 changelog (#22991) (#22995)

Frontport from #22991

19 months agoFix pull request branch selector visible without clicking Edit (#23012)
Brecht Van Lommel [Mon, 20 Feb 2023 16:08:32 +0000 (17:08 +0100)]
Fix pull request branch selector visible without clicking Edit (#23012)

Caused by #22950

19 months agoBump golang.org/x/net from 0.4.0 to 0.7.0 (#22980)
dependabot[bot] [Mon, 20 Feb 2023 15:52:21 +0000 (23:52 +0800)]
Bump golang.org/x/net from 0.4.0 to 0.7.0 (#22980)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to
0.7.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/net/commit/8e2b117aee74f6b86c207a808b0255de45c0a18a"><code>8e2b117</code></a>
http2/hpack: avoid quadratic complexity in hpack decoding</li>
<li><a
href="https://github.com/golang/net/commit/547e7edf3873d6f3a9c093d3785f9e2289e00746"><code>547e7ed</code></a>
http2: avoid referencing ResponseWrite.Write parameter after
returning</li>
<li><a
href="https://github.com/golang/net/commit/39940adcaaa73e661124cb80fb8dd57ea929dbaf"><code>39940ad</code></a>
html: parse comments per HTML spec</li>
<li><a
href="https://github.com/golang/net/commit/87ce33ecb484cbb6bcfc8e506ce0330ef72e0847"><code>87ce33e</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/net/commit/415cb6d518e71d202e2dc2f44c475cbff84eee72"><code>415cb6d</code></a>
all: fix some comments</li>
<li><a
href="https://github.com/golang/net/commit/7e3c19ca52e202ae203b1914fc00c8e47a4d72fa"><code>7e3c19c</code></a>
all: correct typos in comments</li>
<li><a
href="https://github.com/golang/net/commit/296f09aa3817abc1ddff7703799bf9babb7bbd16"><code>296f09a</code></a>
http2: case insensitive handling for 100-continue</li>
<li><a
href="https://github.com/golang/net/commit/f8411da775a685be247bbedcb3ed2c998f895cd2"><code>f8411da</code></a>
nettest: fix tests on dragonfly and js/wasm</li>
<li><a
href="https://github.com/golang/net/commit/8e0e7d8d38f2b6d21d742845570dde2902d06a1d"><code>8e0e7d8</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/net/commit/7805fdc37dc2b54b28b9d621030e14dcf1dab67c"><code>7805fdc</code></a>
http2: rewrite inbound flow control tracking</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/net/compare/v0.4.0...v0.7.0">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.4.0&new-version=0.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)
sillyguodong [Mon, 20 Feb 2023 14:22:34 +0000 (22:22 +0800)]
Fix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)

Close: #22910

---
I'm confused about that why does the api (`GET
/repos/{owner}/{repo}/pulls/{index}/files`) require caller to pass the
parameters `limit` and `page`.
In my case, the caller only needs to pass a `skip-to` to paging. This is
consistent with the api `GET /{owner}/{repo}/pulls/{index}/files`
So, I deleted the code related to `listOptions`

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoonly trigger docs build and publish when docs changed (#22968)
Lunny Xiao [Mon, 20 Feb 2023 13:08:41 +0000 (21:08 +0800)]
only trigger docs build and publish when docs changed (#22968)

Since drone plugin
https://github.com/meltwater/drone-convert-pathschanged/ enabled, we can
filter event with path in drone.

Building docs will now only be triggered when documentations changed.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
19 months agoGet rules by id when editing branch protection rule (#22932)
Zettat123 [Mon, 20 Feb 2023 11:30:41 +0000 (19:30 +0800)]
Get rules by id when editing branch protection rule (#22932)

When users rename an existing branch protection rule, a new rule with
the new name will be created and the old rule will still exist.

![image](https://user-images.githubusercontent.com/15528715/219276442-d3c001ad-e693-44ec-9ad2-b33f2666b49b.png)

---

![image](https://user-images.githubusercontent.com/15528715/219276478-547c3b93-b3f1-4292-a1ef-c1b7747fe1bb.png)

The reason is that the `SettingsProtectedBranchPost` function only get
branch protection rule by name before updating or creating a rule. When
the rule name changes, the function cannot find the existing rule so it
will create a new rule rather than update the existing rule. To fix the
bug, the function should get rule by id first.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix hidden commit status on multiple checks (#22889)
oliverpool [Mon, 20 Feb 2023 08:43:04 +0000 (09:43 +0100)]
Fix hidden commit status on multiple checks (#22889)

Since #22632, when a commit status has multiple checks, no check is
shown at all (hence no way to see the other checks).

This PR fixes this by always adding a tag with the
`.commit-statuses-trigger` to the DOM (the `.vm` is for vertical
alignment).

![2023-02-13-120528](https://user-images.githubusercontent.com/3864879/218441846-1a79c169-2efd-46bb-9e75-d8b45d7cc8e3.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoAdd me to maintainers (#22998)
Zettat123 [Mon, 20 Feb 2023 08:42:02 +0000 (16:42 +0800)]
Add me to maintainers (#22998)

Add me to maintainers.

[List of merged
PRs](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3AZettat123+is%3Amerged)

Co-authored-by: Jason Song <i@wolfogre.com>
19 months agoAdd all units to the units permission list in org team members sidebar (#22971)
yp05327 [Mon, 20 Feb 2023 07:08:33 +0000 (16:08 +0900)]
Add all units to the units permission list in org team members sidebar (#22971)

Add all units to the units permission list in org team members sidebar.

Before:

![BQF448EIHEYKY62XGG(5101](https://user-images.githubusercontent.com/18380374/219877772-b57df8fb-2b82-4b1a-85c8-3809f8751cab.png)
After:

![image](https://user-images.githubusercontent.com/18380374/219877762-f69482b8-abf9-4333-978e-6a3f52039a16.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoMake CI use a dummy password hasher for all tests (#22983)
zeripath [Mon, 20 Feb 2023 05:20:30 +0000 (05:20 +0000)]
Make CI use a dummy password hasher for all tests (#22983)

During the recent hash algorithm change it became clear that the choice
of password hash algorithm plays a role in the time taken for CI to run.

Therefore as attempt to improve CI we should consider using a dummy
hashing algorithm instead of a real hashing algorithm.

This PR creates a dummy algorithm which is then set as the default
hashing algorithm during tests that use the fixtures. This hopefully
will cause a reduction in the time it takes for CI to run.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoUse beforeCommit instead of baseCommit (#22949)
Kyle D [Mon, 20 Feb 2023 03:56:07 +0000 (20:56 -0700)]
Use beforeCommit instead of baseCommit (#22949)

Replaces: https://github.com/go-gitea/gitea/pull/22947
Fixes https://github.com/go-gitea/gitea/issues/22946
Probably related to https://github.com/go-gitea/gitea/issues/19530

Basically, many of the diffs were broken because they were comparing to
the base commit, where a 3-dot diff should be comparing to the [last
common
ancestor](https://matthew-brett.github.io/pydagogue/git_diff_dots.html).

This should have an integration test so that we don’t run into this
issue again.

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
19 months agoAdd comment marking the end of database migrations in `1.19.0` (#22975)
Yarden Shoham [Mon, 20 Feb 2023 02:30:36 +0000 (04:30 +0200)]
Add comment marking the end of database migrations in `1.19.0` (#22975)

There will be no more migrations in `1.19.0`

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
19 months agoFix broken pull request files (#22962)
Lunny Xiao [Mon, 20 Feb 2023 01:57:16 +0000 (09:57 +0800)]
Fix broken pull request files (#22962)

Fix #22961

19 months agoFix avatar misalignment (#22955)
Zettat123 [Sun, 19 Feb 2023 23:07:46 +0000 (07:07 +0800)]
Fix avatar misalignment (#22955)

Fix #22818.

|  Before   | After  |
|  ----  | ----  |
| <img
src="https://user-images.githubusercontent.com/15528715/219617504-d86e7a90-d4ac-4a92-bd8a-100dddc693d5.png"
width="200px" /> | <img
src="https://user-images.githubusercontent.com/15528715/219618645-a4045f65-bda6-49ce-a676-f03a9817bb70.png"
width="200px" />|
| <img
src="https://user-images.githubusercontent.com/15528715/219618013-844ef208-853b-44bd-a67c-36e360f0ffa7.png"
width="200px" /> | <img
src="https://user-images.githubusercontent.com/15528715/219618361-cb13c369-852e-47bf-ae30-e429d348823d.png"
width="200px" /> |

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoRefactor the setting to make unit test easier (#22405)
Lunny Xiao [Sun, 19 Feb 2023 16:12:01 +0000 (00:12 +0800)]
Refactor the setting to make unit test easier (#22405)

Some bugs caused by less unit tests in fundamental packages. This PR
refactor `setting` package so that create a unit test will be easier
than before.

- All `LoadFromXXX` files has been splited as two functions, one is
`InitProviderFromXXX` and `LoadCommonSettings`. The first functions will
only include the code to create or new a ini file. The second function
will load common settings.
- It also renames all functions in setting from `newXXXService` to
`loadXXXSetting` or `loadXXXFrom` to make the function name less
confusing.
- Move `XORMLog` to `SQLLog` because it's a better name for that.

Maybe we should finally move these `loadXXXSetting` into the `XXXInit`
function? Any idea?

---------

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
19 months agoMigration v244.go should be v243.go (#22988)
zeripath [Sun, 19 Feb 2023 14:24:23 +0000 (14:24 +0000)]
Migration v244.go should be v243.go (#22988)

19 months agoAdjust manifest to prevent tagging latest on rcs (#22811)
zeripath [Sun, 19 Feb 2023 14:24:08 +0000 (14:24 +0000)]
Adjust manifest to prevent tagging latest on rcs (#22811)

19 months agoAdd some guidelines for refactoring (#22880)
wxiaoguang [Sun, 19 Feb 2023 13:25:23 +0000 (21:25 +0800)]
Add some guidelines for refactoring (#22880)

Just some brief ideas.

Feel free to complete these guidelines, feel free to edit on this PR
directly.

19 months agoRename `GetUnits` to `LoadUnits` (#22970)
yp05327 [Sun, 19 Feb 2023 08:31:39 +0000 (17:31 +0900)]
Rename `GetUnits` to `LoadUnits` (#22970)

Same as https://github.com/go-gitea/gitea/pull/22967

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoProvide the ability to set password hash algorithm parameters (#22942)
zeripath [Sun, 19 Feb 2023 07:35:20 +0000 (07:35 +0000)]
Provide the ability to set password hash algorithm parameters (#22942)

This PR refactors and improves the password hashing code within gitea
and makes it possible for server administrators to set the password
hashing parameters

In addition it takes the opportunity to adjust the settings for `pbkdf2`
in order to make the hashing a little stronger.

The majority of this work was inspired by PR #14751 and I would like to
thank @boppy for their work on this.

Thanks to @gusted for the suggestion to adjust the `pbkdf2` hashing
parameters.

Close #14751

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix no user listed in org teams page (#22979)
yp05327 [Sun, 19 Feb 2023 04:57:49 +0000 (13:57 +0900)]
Fix no user listed in org teams page (#22979)

https://github.com/go-gitea/gitea/pull/22294 introduced this bug.
Before:

![picture](https://user-images.githubusercontent.com/18380374/219916000-5b28db1a-22b5-481a-807b-49c14ac1cd35.png)
After:

![picture](https://user-images.githubusercontent.com/18380374/219916260-6b94efbb-836a-4551-b6a8-3f9cb37d822a.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoRefactor hiding-methods, remove jQuery show/hide, remove `.hide` class, remove inline...
wxiaoguang [Sun, 19 Feb 2023 04:06:14 +0000 (12:06 +0800)]
Refactor hiding-methods, remove jQuery show/hide, remove `.hide` class, remove inline style=display:none (#22950)

Close #22847

This PR:

* introduce Gitea's own `showElem` and related functions
* remove jQuery show/hide
* remove .hide class
* remove inline style=display:none

From now on:

do not use:
* "[hidden]" attribute: it's too weak, can not be applied to an element
with "display: flex"
* ".hidden" class: it has been polluted by Fomantic UI in many cases
* inline style="display: none": it's difficult to tweak
* jQuery's show/hide/toggle: it can not show/hide elements with
"display: xxx !important"

only use:
* this ".gt-hidden" class
* showElem/hideElem/toggleElem functions in "utils/dom.js"

cc: @silverwind , this is the all-in-one PR

19 months agoScoped labels (#22585)
Brecht Van Lommel [Sat, 18 Feb 2023 19:17:39 +0000 (20:17 +0100)]
Scoped labels (#22585)

Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.

The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.

Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.

In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.

Label rendering refactor for consistency and code simplification:

* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.

Label creation and editing in multiline modal menu:

* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.

Custom exclusive scoped label rendering:

* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.

---------

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
19 months agoRename "People" to "Members" in organization page and use a better icon (#22960)
Yarden Shoham [Sat, 18 Feb 2023 13:41:31 +0000 (15:41 +0200)]
Rename "People" to "Members" in organization page and use a better icon (#22960)

`member` is how it's named in the code

Closes #22931

Before | After
--- | ---

![image](https://user-images.githubusercontent.com/20454870/219781155-69a8476e-0f04-4b70-bda5-ea6fa8ce676c.png)
|
![image](https://user-images.githubusercontent.com/20454870/219780887-61644c27-36a2-4e1f-8f98-be3911883b49.png)

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
19 months agoRename `repo.GetOwner` to `repo.LoadOwner` (#22967)
yp05327 [Sat, 18 Feb 2023 12:11:03 +0000 (21:11 +0900)]
Rename `repo.GetOwner` to `repo.LoadOwner` (#22967)

Fixes https://github.com/go-gitea/gitea/issues/22963

---------

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
19 months agoNotify on container image create (#22806)
KN4CK3R [Sat, 18 Feb 2023 05:36:38 +0000 (06:36 +0100)]
Notify on container image create (#22806)

Fixes #22791

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agowebview: Fix overflowing diff body (#22959)
Ferdinand Thiessen [Sat, 18 Feb 2023 01:47:06 +0000 (02:47 +0100)]
webview: Fix overflowing diff body (#22959)

If the content is quite large the diff body overflows the container and
can not be read.
This is fixed by setting the diff body maximum width to 100% and enable
overflow scrollbars:

before | after
---|---

![Screenshot_20230217_184716](https://user-images.githubusercontent.com/1855448/219733934-75bec38c-7cfe-47bb-b001-b090c02b769e.png)
|
![Screenshot_20230217_184655](https://user-images.githubusercontent.com/1855448/219733971-4db092d1-ffcb-4298-a640-f740a3ac430b.png)

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
19 months agoIntroduce customized HTML elements, fix incorrect AppUrl usages in templates (#22861)
wxiaoguang [Fri, 17 Feb 2023 14:02:20 +0000 (22:02 +0800)]
Introduce customized HTML elements, fix incorrect AppUrl usages in templates (#22861)

This PR follows:
* #21986
* #22831

This PR also introduce customized HTML elements, which would also help
problems like:
* #17760
* #21429
* #21440

With customized HTML elements, there won't be any load-search-replace
operations, and it can avoid page flicking (which @silverwind cares a
lot).

Browser support:
https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements

# FAQ

## Why the component has the prefix?

As usual, I would strongly suggest to add prefixes for our own/private
names. The dedicated prefix will avoid conflicts in the future, and it
makes it easier to introduce various 3rd components, like GitHub's
`relative-time` component. If there is no prefix, it's impossible to
introduce another public component with the same name in the future.

## Why the `custcomp.js` is loaded before HTML body? The `index.js` is
after HTML body.

Customized components must be registered before the content loading.
Otherwise there would be still some flicking.

`custcomp.js` should have its own dependencies and should be very light,
so it won't affect the page loading time too much.

## Why use `data-url` attribute but not use the `textContent`?

According to the standard, the `connectedCallback` occurs on the
tag-opening moment. The element's children are not ready yet.

## Why not use `{{.GuessCurrentOrigin $.ctx ...}}` to let backend decide
the absolute URL?

It's difficult for backend to guess the correct protocol(scheme)
correctly with zero configuration. Generating the absolute URL from
frontend can guarantee that the URL is 100% correct -- since the user is
visiting it.

# Screenshot

<details>

![image](https://user-images.githubusercontent.com/2114189/218256757-a267c8ba-3108-4755-9ae5-329f1b08f615.png)

</details>

19 months agoSort issues and pulls by recently updated in user and organization home (#22925)
Brecht Van Lommel [Fri, 17 Feb 2023 07:13:35 +0000 (08:13 +0100)]
Sort issues and pulls by recently updated in user and organization home (#22925)

The main purpose of these home pages should be getting an overview of
what's going on or needs attention. Recently updated is a better default
than newest for that purpose, to avoid missing active issues and pulls
that were not created recently.

The default sorting order in repository issues and pulls remains newest.
Repositories in an organization are already sorted by recently updated.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix 404 error viewing the LFS file (#22945)
Zettat123 [Fri, 17 Feb 2023 03:55:33 +0000 (11:55 +0800)]
Fix 404 error viewing the LFS file (#22945)

Fix #22734.

According to
[`view_file.tmpl`](https://github.com/go-gitea/gitea/blob/main/templates/repo/view_file.tmpl#L82),
`lfs_file.tmpl` should use `AssetUrlPrefix` instead of `AppSubUrl`.

Co-authored-by: Jason Song <i@wolfogre.com>
19 months agoAlways go full width in PR view (#22844)
gempir [Thu, 16 Feb 2023 19:25:00 +0000 (20:25 +0100)]
Always go full width in PR view (#22844)

This is an alternative solution to #22824
and would also close #22781

This makes the PR diff view always full width.
It makes sense to make use of that screen real estate. If you want a
more narrow view you can always resize your browser.
It also avoids cluttering the UI with another button + the database with
another column for the setting.

This is also how github and gitlab do it.

19 months agoIncrease Content field size of gpg_key_import to MEDIUMTEXT (#22897)
zeripath [Thu, 16 Feb 2023 18:08:40 +0000 (18:08 +0000)]
Increase Content field size of gpg_key_import to MEDIUMTEXT (#22897)

Unfortunately #20896 does not completely prevent Data too long issues
and GPGKeyImport needs to be increased too.

Fix #22896

Signed-off-by: Andrew Thornton <art27@cantab.net>
19 months agoFix context bug (#22940)
Lunny Xiao [Thu, 16 Feb 2023 17:20:53 +0000 (01:20 +0800)]
Fix context bug (#22940)

Fix https://try.gitea.io/wxiaoguang/test/issues/19

19 months agoAllow custom "created" timestamps in user creation API (#22549)
Sybren [Thu, 16 Feb 2023 16:32:01 +0000 (17:32 +0100)]
Allow custom "created" timestamps in user creation API (#22549)

Allow back-dating user creation via the `adminCreateUser` API operation.
`CreateUserOption` now has an optional field `created_at`, which can
contain a datetime-formatted string. If this field is present, the
user's `created_unix` database field will be updated to its value.

This is important for Blender's migration of users from Phabricator to
Gitea. There are many users, and the creation timestamp of their account
can give us some indication as to how long someone's been part of the
community.

The back-dating is done in a separate query that just updates the user's
`created_unix` field. This was the easiest and cleanest way I could
find, as in the initial `INSERT` query the field always is set to "now".

19 months agoUse "Title Case" for text "Reference in new issue" (#22936)
Dalai Felinto [Thu, 16 Feb 2023 15:06:07 +0000 (16:06 +0100)]
Use "Title Case" for text "Reference in new issue" (#22936)

The "Reference in new issue" option shows up in a menu when looking at
pull requests. All the other options there follow the "Title case":

* Copy Link
* Quote Reply
* Edit

This patch makes sure this option also follow the Title case.

Screenshot of how it looks without this patch:

![image](https://user-images.githubusercontent.com/843498/219346003-728d07c1-d150-41a5-b084-faef118228b1.png)

Co-authored-by: Dalai Felinto <dalai@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFirst step to refactor the `.hide` to `.gt-hidden` (#22916)
wxiaoguang [Thu, 16 Feb 2023 12:07:21 +0000 (20:07 +0800)]
First step to refactor the `.hide` to `.gt-hidden` (#22916)

A separate PR from #22884 (without touching the jQuery methods)

19 months agoAdd continue option to backport.go (#22930)
zeripath [Thu, 16 Feb 2023 09:48:08 +0000 (09:48 +0000)]
Add continue option to backport.go (#22930)

Sometimes it can be helpful to continue from a broken cherry-pick. This
PR adds another option which can be used to determine the version and pr
number from the current branch name instead of reading the config.yaml
file.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
20 months agoAdd `title` to PR file tree items (#22918)
delvh [Thu, 16 Feb 2023 05:57:25 +0000 (06:57 +0100)]
Add `title` to PR file tree items (#22918)

Previously, a file/directory name was simply cut when it was too long.
Now, we display the browser-native tooltip (`title`) instead, so you can
still see it when hovering over it.
In this case, we don't use the normal `tippy` tooltips for three
reasons:
1. Vue components are not included in the global tooltip initialization
2. Vue components would need to initialize their tooltips themselves
whenever their content is changed
3. The tooltips are shown too long under the default configuration (the
tooltip one element above is still shown when hovering on the element
below)

Fixes #22915

## Appearance

![image](https://user-images.githubusercontent.com/51889757/219049642-43668a38-0e86-42bf-a1d0-3742c4dc7fd9.png)

## Room for future improvement

We could think about displaying the whole file path in the title, not
just its name.
This is not done at the moment:

![image](https://user-images.githubusercontent.com/51889757/219050689-1e6e3d57-f2bf-48be-8553-415e744a6e10.png)

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoFix shabox regression (#22924)
Gusted [Thu, 16 Feb 2023 01:37:11 +0000 (02:37 +0100)]
Fix shabox regression (#22924)

- Regression from https://github.com/go-gitea/gitea/pull/22294

Error:

![image](https://user-images.githubusercontent.com/25481501/219115669-52b98fdb-bcbb-430d-a205-beb305c37e85.png)

20 months agofix incorrect role labels for migrated issues and comments (#22914)
Zettat123 [Wed, 15 Feb 2023 17:29:13 +0000 (01:29 +0800)]
fix incorrect role labels for migrated issues and comments (#22914)

Fix #22797.

## Reason
If a comment was migrated from other platforms, this comment may have an
original author and its poster is always not the original author. When
the `roleDescriptor` func get the poster's role descriptor for a
comment, it does not check if the comment has an original author. So the
migrated comments' original authors might be marked as incorrect roles.

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoAlways show the `command line instructions` button even if there are conflicts (...
wxiaoguang [Wed, 15 Feb 2023 15:31:35 +0000 (23:31 +0800)]
Always show the `command line instructions` button even if there are conflicts (#22909)

Always show the `command line instructions` button even if there are
conflicts.

20 months agoRemove thehowl from maintainers (#22917)
Morgan [Wed, 15 Feb 2023 14:35:46 +0000 (15:35 +0100)]
Remove thehowl from maintainers (#22917)

20 months agoAdd context cache as a request level cache (#22294)
Lunny Xiao [Wed, 15 Feb 2023 13:37:34 +0000 (21:37 +0800)]
Add context cache as a request level cache (#22294)

To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.

But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.

The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx  context.Context
data map[any]map[any]any
        lock sync.RWMutex
}

var cacheContextKey = struct{}{}

func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx:  ctx,
data: make(map[any]map[any]any),
})
}
```

Then you can use the below 4 methods to read/write/del the data within
the same context.

```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```

Then let's take a look at how `system.GetString` implement it.

```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```

First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.

An object stored in the context cache will only be destroyed after the
context disappeared.

20 months agoAdd tooltip to issue reference (#22913)
delvh [Wed, 15 Feb 2023 11:34:10 +0000 (12:34 +0100)]
Add tooltip to issue reference (#22913)

Previously, you had no idea what you are copying with the issue
reference button for either long repo names, user names, or issue
indexes.
Now, it is simply a bit redundant for short references but a lot easier
for long references.

## Before

![image](https://user-images.githubusercontent.com/51889757/218995943-3b609ee9-4138-49ce-99b1-73fb1ea80280.png)

## After

![image](https://user-images.githubusercontent.com/51889757/218996119-4b6bf6c1-abfa-4618-81ca-a72914e73eb8.png)

20 months agoAdd command to bulk set must-change-password (#22823)
zeripath [Tue, 14 Feb 2023 22:12:19 +0000 (22:12 +0000)]
Add command to bulk set must-change-password (#22823)

As part of administration sometimes it is appropriate to forcibly tell
users to update their passwords.

This PR creates a new command `gitea admin user must-change-password`
which will set the `MustChangePassword` flag on the provided users.

Signed-off-by: Andrew Thornton <art27@cantab.net>
20 months agoRemember to attach the parent tree when converting TreeEntry() -> Tree() (#22902)
Nick [Tue, 14 Feb 2023 21:23:04 +0000 (16:23 -0500)]
Remember to attach the parent tree when converting TreeEntry() -> Tree() (#22902)

!fixup https://github.com/go-gitea/gitea/pull/22177

The only place this function is used so far is in
findReadmeFileInEntries(), so the only visible effect of this oversight
was in an obscure README-related corner: if the README was in a
subfolder and was a symlink that pointed up, as in .github/README.md ->
../docs/old/setup.md, the README would fail to render when FollowLinks()
hit the nil ptree. This makes the ptree non-nil and thus repairs it.

20 months agoFix dark-colored description text in arc-green theme (#22908)
Zettat123 [Tue, 14 Feb 2023 19:05:19 +0000 (03:05 +0800)]
Fix dark-colored description text in arc-green theme (#22908)

Fix #22873.

20 months agoFix the full-height problem for all pages (#22905)
wxiaoguang [Tue, 14 Feb 2023 13:04:22 +0000 (21:04 +0800)]
Fix the full-height problem for all pages (#22905)

Really fix #22883, close #22901

I made a mistake that the global styles in RepoActionView.vue could
still pollute global styles (I forgot that the code of this component is
still loaded on every page, instead of loaded on demand)

This PR makes a complete fix: only change the page's full-height
behavior if the component is used.

Screenshot after the fix:

<details>

![image](https://user-images.githubusercontent.com/2114189/218664776-0dbcd469-2c36-4e17-972f-e44fa3b81ba6.png)

</details>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoRemove Fomantic-UI's `.hidden` CSS class for menu elements (#22895)
wxiaoguang [Tue, 14 Feb 2023 11:53:54 +0000 (19:53 +0800)]
Remove Fomantic-UI's `.hidden` CSS class for menu elements (#22895)

* Like #22851
* All other dropdown menu elements do not have such `hidden` class.
* Actually the dropdown menu elements do not need it in HTML, so this PR
removes it.
* There is already `.ui.dropdown .menu { display: none; }`, so when
loading the page, the menu is correctly hidden initially, no need to add
any more CSS classes.
* The Fomantic UI's `.hidden` class should still exist until there is no
its checkbox/dropdown module anymore. The Fomantic UI JS code still
addes `hidden` for `ui checkbox` and addes `transition hidden` for `ui
menu` at the moment.
* This PR also cleans the legacy inline `style`, which is quite hacky
and no need anymore.

All these dropdown menus work well.

I have tested these 5 places:

* The code search from User Profile
* The issue sidebar to lock issue
* The repo search form
* The repo setting page: branch list
* The repo setting page: merge option list

Screenshot:

![image](https://user-images.githubusercontent.com/2114189/218534515-e7dfe291-6765-4e0b-833c-b74f17e30117.png)

20 months agoMove `IsReadmeFile*` from `modules/markup/` to `modules/util` (#22877)
Nick [Mon, 13 Feb 2023 20:01:09 +0000 (15:01 -0500)]
Move `IsReadmeFile*` from `modules/markup/` to `modules/util` (#22877)

These functions don't examine contents, just filenames, so they don't
fit in well in a markup module.

This was originally part of
https://github.com/go-gitea/gitea/pull/22177.

Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
20 months agoMove helpers to be prefixed with `gt-` (#22879)
zeripath [Mon, 13 Feb 2023 17:59:59 +0000 (17:59 +0000)]
Move helpers to be prefixed with `gt-` (#22879)

As discussed in #22847 the helpers in helpers.less need to have a
separate prefix as they are causing conflicts with fomantic styles

This will allow us to have the `.gt-hidden { display:none !important; }`
style that is needed to for the reverted PR.

Of note in doing this I have noticed that there was already a conflict
with at least one chroma style which this PR now avoids.

I've also added in the `gt-hidden` style that matches the tailwind one
and switched the code that needed it to use that.

Signed-off-by: Andrew Thornton <art27@cantab.net>
---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 months agoRemove _actions.less (#22885)
Jason Song [Mon, 13 Feb 2023 14:33:33 +0000 (22:33 +0800)]
Remove _actions.less (#22885)

Fix #22883.

Revert commit 59beb2dba6b35b88dae5ac5c3d094bc6c1bba19c.

20 months agoHighlight focused diff file (#22870)
delvh [Mon, 13 Feb 2023 10:46:47 +0000 (11:46 +0100)]
Highlight focused diff file (#22870)

When a diff file has been focused through the URL ID fragment, it will
be highlighted.

![light
theme](https://user-images.githubusercontent.com/51889757/218283880-ce551cb3-0c21-4044-adb0-d9ceb8a15ec5.png)
![dark
theme](https://user-images.githubusercontent.com/51889757/218283885-e96e989a-4670-49b6-9733-fbd6fffabf20.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoPull Requests: setting to allow edits by maintainers by default, tweak UI (#22862)
Brecht Van Lommel [Mon, 13 Feb 2023 06:09:52 +0000 (07:09 +0100)]
Pull Requests: setting to allow edits by maintainers by default, tweak UI (#22862)

Add setting to allow edits by maintainers by default, to avoid having to
often ask contributors to enable this.

This also reorganizes the pull request settings UI to improve clarity.
It was unclear which checkbox options were there to control available
merge styles and which merge styles they correspond to.

Now there is a "Merge Styles" label followed by the merge style options
with the same name as in other menus. The remaining checkboxes were
moved to the bottom, ordered rougly by typical order of operations.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agodocs: Update translation from-binary.zh-cn.md (#22820)
Xinyu Zhou [Mon, 13 Feb 2023 05:14:51 +0000 (13:14 +0800)]
docs: Update translation from-binary.zh-cn.md (#22820)

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoMove delete user to service (#22478)
Lunny Xiao [Mon, 13 Feb 2023 05:11:41 +0000 (13:11 +0800)]
Move delete user to service (#22478)

Move delete user to service

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoRemove Fomantic-UI's `.hidden` CSS class for checkbox elements (#22851)
wxiaoguang [Mon, 13 Feb 2023 03:16:59 +0000 (11:16 +0800)]
Remove Fomantic-UI's `.hidden` CSS class for checkbox elements (#22851)

Fomantic-UI's `.hidden` CSS class is badly designed.

* Checkbox elements do not need it in HTML, so this PR removes it (JS
adds the `.hidden` class back by `$('.ui.checkbox').checkbox()`)
* `menu transaction hidden` is still needed, and it should be the only
usage for the `.hidden` from now on (until they get refactored properly)

Co-authored-by: zeripath <art27@cantab.net>
20 months agoAdd some headings to repo views (#22869)
Felipe Leopoldo Sologuren Gutiérrez [Sun, 12 Feb 2023 12:20:12 +0000 (09:20 -0300)]
Add some headings to repo views (#22869)

* Add role heading level 1 to username/repo title.
* Copy behaviour of Releases to some other views.

Contributed by @Forgejo.

![Screenshot with
h2](https://user-images.githubusercontent.com/5055343/218287363-dfae9ab2-7297-4367-ab64-ab141506e131.png)
![Screenshot with former
div](https://user-images.githubusercontent.com/5055343/218287419-77d0ed56-935d-492f-b3ed-71051d169ba8.png)

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix style of actions rerun button (#22835)
Jason Song [Sun, 12 Feb 2023 11:19:50 +0000 (19:19 +0800)]
Fix style of actions rerun button (#22835)

Authored by @a1012112796 at
https://github.com/go-gitea/gitea/pull/22798#issuecomment-1421820001

Avoid putting `button` in `a`.

A patch for #22798 .

Now it looks like:

<img width="393" alt="image"
src="https://user-images.githubusercontent.com/9418365/217791913-b491fc86-ee9b-4672-80ea-7286eef2d11f.png">
<img width="389" alt="image"
src="https://user-images.githubusercontent.com/9418365/217791967-d8c09c8b-4cea-4011-b01e-db0d1333e7f6.png">

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoMake issue and code search support camel case (#22829)
sillyguodong [Sun, 12 Feb 2023 10:09:03 +0000 (18:09 +0800)]
Make issue and code search support camel case (#22829)

Fixes #22714
### Changes:
1. Add a token filter which named "camelCase" between custom unicode
token filter and "to_lower" token filter when add custom analyzer.

### Notice:
If users want this feature to work, they should delete folder under
{giteaPath}/data/indexers and restart application. Then application will
create a new IndexMapping.

### Screenshots:

![image](https://user-images.githubusercontent.com/33891828/217715692-c18c41f2-57a1-4727-861c-470935c8e0c8.png)

### Others:
I originally attempted to give users the ability to configure the
"token_filters" in the "app.ini" file. But I found that if users does
not strictly follow a right order to register "token_filters", they
won't get the expected results. I think it is difficult to ask users to
do this. So I finally give up this idea.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoRevert "Fix notification and stopwatch empty states" (#22876)
Lunny Xiao [Sun, 12 Feb 2023 08:18:07 +0000 (16:18 +0800)]
Revert "Fix notification and stopwatch empty states" (#22876)

Per https://github.com/go-gitea/gitea/pull/22845#issuecomment-1426950234

Reverts go-gitea/gitea#22845

Let's have a better PR.

@silverwind @zeripath

Co-authored-by: zeripath <art27@cantab.net>
20 months agoDeduplicate findReadmeFile() (#22177)
Nick [Sun, 12 Feb 2023 07:08:10 +0000 (02:08 -0500)]
Deduplicate findReadmeFile() (#22177)

This code was copy-pasted at some point. Revisit it to reunify it.

~~Doing that then encouraged simplifying the types of a couple of
related functions.~~

~~As a follow-up, move two helper functions, `isReadmeFile()` and
`isReadmeFileExtension()`, intimately tied to `findReadmeFile()`, in as
package-private.~~

Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
20 months agoFix milestone title font problem (#22863)
wxiaoguang [Sun, 12 Feb 2023 03:19:09 +0000 (11:19 +0800)]
Fix milestone title font problem (#22863)

Replace #22853 since it's closed, and actually there are 2 places need
to be fixed.

~~Follow @fsologureng 's suggestion to keep the `<hX>` tags.~~

Update: from fsologureng: this doesn't change anything from a11y's point
of view. So I think this PR could be fine to fix the UI looking problems
as a quick patch, then defer the a11y problems to new PRs together.

Before: the font-size is too large.

After: it seems better.

![image](https://user-images.githubusercontent.com/2114189/218266257-fc2d5872-9e96-4c6a-87ea-f27531ac15c0.png)

![image](https://user-images.githubusercontent.com/2114189/218266247-efc09d83-405f-4495-967a-30d9744134ce.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix PR file tree folders no longer collapsing (#22864)
gempir [Sun, 12 Feb 2023 02:34:46 +0000 (03:34 +0100)]
Fix PR file tree folders no longer collapsing (#22864)

Collapsing folders currently just throws a console error

```
index.js?v=1.19.0~dev-403-gb6b8feb3d:10 TypeError: this.$set is not a function
    at Proxy.handleClick (index.js?v=1.19.0~dev-403-gb6b8feb3d:58:7159)
    at index.js?v=1.19.0~dev-403-gb6b8feb3d:58:6466
    at index.js?v=1.19.0~dev-403-gb6b8feb3d:10:93922
    at ce (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:1472)
    at Q (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:1567)
    at HTMLDivElement.$e (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:79198)
```

This PR fixes this and allows folders to be collapsed again.

Also:
- better cursor interaction with folders
- added some color to the diff detail stats
- remove green link color from all the file names

Screenshots:

![image](https://user-images.githubusercontent.com/9765622/218269712-2f3dda55-6d70-407f-8d34-2a5d9c8df548.png)

![image](https://user-images.githubusercontent.com/9765622/218269714-6ce8a954-daea-4ed6-9eea-8b2323db4d8f.png)

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoescape filename when assemble URL (#22850)
sillyguodong [Sun, 12 Feb 2023 01:31:14 +0000 (09:31 +0800)]
escape filename when assemble URL (#22850)

Fixes: #22843
### Cause:

https://github.com/go-gitea/gitea/blob/affdd40296960a08a4223330ccbd1fb88c96ea1a/services/repository/files/content.go#L161

Previously, we did not escape the **"%"** that might be in "treePath"
when call "url.parse()".

![image](https://user-images.githubusercontent.com/33891828/218066318-5a909e50-2a17-46e6-b32f-684b2aa4b91f.png)

This function will check whether "%" is the beginning of an escape
character. Obviously, the "%" in the example (hello%mother.txt) is not
that. So, the function will return a error.

### Solution:
We can escape "treePath" by call "url.PathEscape()" function firstly.

### Screenshot:

![image](https://user-images.githubusercontent.com/33891828/218069781-1a030f8b-18d0-4804-b0f8-73997849ef43.png)

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
20 months agoFix notification and stopwatch empty states (#22845)
silverwind [Sat, 11 Feb 2023 21:45:58 +0000 (22:45 +0100)]
Fix notification and stopwatch empty states (#22845)

Previous solution was relying on fomantic selector `.ui.label.hidden` to
hide the elements in their empty state, but this doesn't work any more
with the removal of the `label` class. Instead, introduce a standalone
CSS rule for the `hidden` class, which is universally usable as a single
class.

We can unfortunately not use the existing `hide` class because without
the `!important`, it does not have enough specificity to win against
fomantic's `.ui.menu:not(.vertical) .item {display: flex}` rule.

Followup and fixes regression from
https://github.com/go-gitea/gitea/pull/22169.

Before:

<img width="98" alt="image"
src="https://user-images.githubusercontent.com/115237/217959380-d3279ff3-526a-4ac4-9a18-3ab7c9ae91dd.png">

After:

<img width="77" alt="image"
src="https://user-images.githubusercontent.com/115237/217959463-44852716-cb25-4110-8481-668842ad4454.png">

20 months agoFix .golangci.yml (#22868)
zeripath [Sat, 11 Feb 2023 21:44:53 +0000 (21:44 +0000)]
Fix .golangci.yml (#22868)

When we updated the .golangci.yml for 1.20 we should have used a string
as 1.20 is not a valid number.

In doing so we need to restore the nolint markings within the pq driver.

Signed-off-by: Andrew Thornton <art27@cantab.net>
20 months agoFix migration issue. (#22867)
Nathaniel Sabanski [Sat, 11 Feb 2023 21:28:41 +0000 (13:28 -0800)]
Fix migration issue. (#22867)

See:
https://github.com/go-gitea/gitea/pull/22112#issuecomment-1426872992

20 months agoAdd `/$count` endpoints for NuGet v2 (#22855)
KN4CK3R [Sat, 11 Feb 2023 11:30:44 +0000 (12:30 +0100)]
Add `/$count` endpoints for NuGet v2 (#22855)

Fixes #22838

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoPreview images for Issue cards in Project Board view (#22112)
Nathaniel Sabanski [Sat, 11 Feb 2023 08:12:41 +0000 (00:12 -0800)]
Preview images for Issue cards in Project Board view (#22112)

Original Issue: https://github.com/go-gitea/gitea/issues/22102

This addition would be a big benefit for design and art teams using the
issue tracking.

The preview will be the latest "image type" attachments on an issue-
simple, and allows for automatic updates of the cover image as issue
progress is made!

This would make Gitea competitive with Trello... wouldn't it be amazing
to say goodbye to Atlassian products? Ha.

First image is the most recent, the SQL will fetch up to 5 latest images
(URL string).

All images supported by browsers plus upcoming formats: *.avif *.bmp
*.gif *.jpg *.jpeg *.jxl *.png *.svg *.webp

The CSS will try to center-align images until it cannot, then it will
left align with overflow hidden. Single images get to be slightly
larger!

Tested so far on: Chrome, Firefox, Android Chrome, Android Firefox.

Current revision with light and dark themes:

![image](https://user-images.githubusercontent.com/24665/207066878-58e6bf73-0c93-4caa-8d40-38f4432b3578.png)

![image](https://user-images.githubusercontent.com/24665/207066555-293f65c3-e706-4888-8516-de8ec632d638.png)

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
20 months agoFix improper HTMLURL usages in Go code (#22839)
wxiaoguang [Sat, 11 Feb 2023 06:34:11 +0000 (14:34 +0800)]
Fix improper HTMLURL usages in Go code (#22839)

In Go code, HTMLURL should be only used for external systems, like
API/webhook/mail/notification, etc.

If a URL is used by `Redirect` or rendered in a template, it should be a
relative URL (aka `Link()` in Gitea)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoUse proxy for pull mirror (#22771)
Gusted [Sat, 11 Feb 2023 00:39:50 +0000 (01:39 +0100)]
Use proxy for pull mirror (#22771)

- Use the proxy (if one is specified) for pull mirrors syncs.
- Pulled the code from
https://github.com/go-gitea/gitea/blob/c2774d9e80d9a436d9c2044960369c4db227e3a0/modules/git/repo.go#L164-L170

Downstream issue: https://codeberg.org/forgejo/forgejo/issues/302

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
20 months agoMake issue title edit buttons focusable and fix incorrect ajax requests (#22807)
wxiaoguang [Thu, 9 Feb 2023 17:11:16 +0000 (01:11 +0800)]
Make issue title edit buttons focusable and fix incorrect ajax requests (#22807)

Replace #19922 , which is stale since my last review:
https://github.com/go-gitea/gitea/pull/19922#pullrequestreview-1003546506
and https://github.com/go-gitea/gitea/pull/19922#issuecomment-1153181546

Close #19769

Changes:
1. Use `<button>` instead of `<div>` for buttons
2. Prevent default event handler in `initGlobalButtonClickOnEnter`
3. Fix the incorrect call to `pullrequest_targetbranch_change`
4. Add a slight margin-left to the input element to make UI look better

The logic in repo-issue.js is not ideal, but this PR isn't going to
touch the logic.

This is also an example for future developers to understand how to make
buttons work properly.

### Before

![image](https://user-images.githubusercontent.com/2114189/217262515-ec0462f7-7051-46a5-bfa2-2f6c6a807b7d.png)

### After

* Add a slight margin-left.
* The `Cancel` button is focused.

![image](https://user-images.githubusercontent.com/2114189/217264891-934c9c8d-d190-4866-98b5-666cea57e28d.png)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoFix update by rebase being wrongly disabled by protected base branch (#22825)
Brecht Van Lommel [Thu, 9 Feb 2023 17:08:42 +0000 (18:08 +0100)]
Fix update by rebase being wrongly disabled by protected base branch (#22825)

The branch this is force pushing to is the head branch in the head repo,
so it should be checking if that is protected, not the base.

20 months agoFix inconsistent Filter Project name in issue list (#22827)
Brecht Van Lommel [Thu, 9 Feb 2023 16:39:31 +0000 (17:39 +0100)]
Fix inconsistent Filter Project name in issue list (#22827)

Use Project instead of Filter Project like the other filter menus.

20 months agoFix more HTMLURL in templates (#22831)
wxiaoguang [Thu, 9 Feb 2023 16:31:30 +0000 (00:31 +0800)]
Fix more HTMLURL in templates (#22831)

I haven't tested `runs_list.tmpl` but I think it could be right.

After this PR, besides the `<meta .. HTMLURL>` in html head, the only
explicit HTMLURL usage is in `pull_merge_instruction.tmpl`, which
doesn't affect users too much and it's difficult to fix at the moment.

There are still many usages of `AppUrl` in the templates (eg: the
package help manual), they are similar problems as the HTMLURL in
pull_merge_instruction, and they might be fixed together in the future.

Diff without space:
https://github.com/go-gitea/gitea/pull/22831/files?diff=unified&w=1

20 months agoFix unmatched div in project filter (#22832)
John Olheiser [Thu, 9 Feb 2023 16:15:07 +0000 (10:15 -0600)]
Fix unmatched div in project filter (#22832)

(Note that the below screenshots aren't the same repo, the former is try
and the latter is local)

Before

![div-before](https://user-images.githubusercontent.com/42128690/217723899-a15da77f-a196-4b23-a157-e7f1e1979610.png)

After

![div-after](https://user-images.githubusercontent.com/42128690/217723878-e54235bc-a7d7-425e-bd0d-47d1814f18ba.png)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoImprove AppUrl/ROOT_URL checking (#22836)
wxiaoguang [Thu, 9 Feb 2023 16:14:45 +0000 (00:14 +0800)]
Improve AppUrl/ROOT_URL checking (#22836)

After some PRs:
* #21986
* #22795
* #22808
* #22831
* #22839

Users won't be affected by the ROOT_URL problem in most cases. Close
#19345

This PR improves AppUrl/ROOT_URL checking, only check it on the admin
page, and the message is also updated.

Feel free to suggest about more English-native messages.

![image](https://user-images.githubusercontent.com/2114189/217811809-7d44ddb7-2c4a-46d0-a5db-8ae6ee65f8c3.png)

20 months agoFix isAllowed of escapeStreamer (#22814)
Jason Song [Thu, 9 Feb 2023 12:51:36 +0000 (20:51 +0800)]
Fix isAllowed of escapeStreamer (#22814)

The use of `sort.Search` is wrong: The slice should be sorted, and
`return >= 0` doen't mean it exists, see the
[manual](https://pkg.go.dev/sort#Search).

Could be fixed like this if we really need it:

```diff
diff --git a/modules/charset/escape_stream.go b/modules/charset/escape_stream.go
index 823b63513..fcf1ffbc1 100644
--- a/modules/charset/escape_stream.go
+++ b/modules/charset/escape_stream.go
@@ -20,6 +20,9 @@ import (
 var defaultWordRegexp = regexp.MustCompile(`(-?\d*\.\d\w*)|([^\` + "`" + `\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s\x00-\x1f]+)`)

 func NewEscapeStreamer(locale translation.Locale, next HTMLStreamer, allowed ...rune) HTMLStreamer {
+       sort.Slice(allowed, func(i, j int) bool {
+               return allowed[i] < allowed[j]
+       })
        return &escapeStreamer{
                escaped:                 &EscapeStatus{},
                PassthroughHTMLStreamer: *NewPassthroughStreamer(next),
@@ -284,14 +287,8 @@ func (e *escapeStreamer) runeTypes(runes ...rune) (types []runeType, confusables
 }

 func (e *escapeStreamer) isAllowed(r rune) bool {
-       if len(e.allowed) == 0 {
-               return false
-       }
-       if len(e.allowed) == 1 {
-               return e.allowed[0] == r
-       }
-
-       return sort.Search(len(e.allowed), func(i int) bool {
+       i := sort.Search(len(e.allowed), func(i int) bool {
                return e.allowed[i] >= r
-       }) >= 0
+       })
+       return i < len(e.allowed) && e.allowed[i] == r
 }
```

But I don't think so, a map is better to do it.

20 months agoMake clone URL use current page's host (#22808)
wxiaoguang [Thu, 9 Feb 2023 09:29:13 +0000 (17:29 +0800)]
Make clone URL use current page's host (#22808)

Follow #21986

Even if the ROOT_URL is incorrect, the clone URL on the UI should be
correct.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agochange org_type.go to visible_type.go and fix the notes (#22752)
yp05327 [Thu, 9 Feb 2023 06:40:34 +0000 (15:40 +0900)]
change org_type.go to visible_type.go and fix the notes (#22752)

It seems `VisibleType` is only designed for org at first. But it is also
used by user's visibility now.
So I think `org_type.go` can be changed to `visible_type.go`.

20 months agoImprove notification and stopwatch styles (#22169)
silverwind [Thu, 9 Feb 2023 05:42:18 +0000 (06:42 +0100)]
Improve notification and stopwatch styles (#22169)

- Add dot-style indicators to notification and time tracker
- Slightly reduce whitespace between right-aligned icons
- Move notification icon to right on mobile
- Switch menu icon to SVG

<img width="270" alt="Screenshot 2022-12-19 at 19 40 32"
src="https://user-images.githubusercontent.com/115237/208496795-ce8734a0-f109-47b7-8eb8-96931e867b23.png">
<img width="607" alt="Screenshot 2022-12-19 at 19 41 04"
src="https://user-images.githubusercontent.com/115237/208496797-2ff68197-f520-4174-927e-ead15addd63e.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix blame view missing lines (#22826)
Brecht Van Lommel [Thu, 9 Feb 2023 03:51:02 +0000 (04:51 +0100)]
Fix blame view missing lines (#22826)

Creating a new buffered reader for every part of the blame can miss
lines, as it will read and buffer bytes that the next buffered reader
will not get.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoLoad issue before accessing index in merge message (#22822)
John Olheiser [Thu, 9 Feb 2023 02:47:52 +0000 (20:47 -0600)]
Load issue before accessing index in merge message (#22822)

Fixes #22821

Signed-off-by: jolheiser <john.olheiser@gmail.com>
20 months agoinclude build info in Prometheus metrics (#22819)
Michal [Wed, 8 Feb 2023 17:54:01 +0000 (18:54 +0100)]
include build info in Prometheus metrics (#22819)

Related to: https://github.com/go-gitea/gitea/issues/18061

This PR adds build info to the Prometheus metrics. This includes:
- goarch: https://pkg.go.dev/runtime#GOARCH
- goos: https://pkg.go.dev/runtime#pkg-constants
- goversion: https://pkg.go.dev/runtime#Version
- gitea version: just exposes the existing
code.gitea.io/gitea/modules/setting.AppVer

It's a similar approach to what some other Golang projects are doing,
e.g. Prometheus:
https://github.com/prometheus/common/blob/main/version/info.go

example /metrics response from Prometheus:
```
# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build.
# TYPE prometheus_build_info gauge
prometheus_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.19.4",revision="c0d8a56c69014279464c0e15d8bfb0e153af0dab",version="2.41.0"} 1
```

/metrics response from gitea with this PR:
```
# HELP gitea_build_info Build information
# TYPE gitea_build_info gauge
gitea_build_info{goarch="amd64",goos="linux",goversion="go1.20",version="2c6cc0b8c"} 1
```

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
<!--

Please check the following:

1. Make sure you are targeting the `main` branch, pull requests on
release branches are only allowed for bug fixes.
2. Read contributing guidelines:
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting
(if any)

-->

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
20 months agoFix rerun button of Actions (#22798)
Jason Song [Wed, 8 Feb 2023 07:55:57 +0000 (15:55 +0800)]
Fix rerun button of Actions (#22798)

When clicking the return button, the page should be refreshed. However,
the browser may cancel the previous fetch request, and it fails to rerun
the job. It's easier to reproduce the bug in Safari or Firefox than
Chrome for some reason.

<img width="384" alt="image"
src="https://user-images.githubusercontent.com/9418365/217142792-a783f9a1-7089-44db-b7d8-46c46c72d284.png">

<img width="752" alt="image"
src="https://user-images.githubusercontent.com/9418365/217132406-b8381b63-b323-474e-935b-2596b1b5c046.png">

20 months agoMap OIDC groups to Orgs/Teams (#21441)
KN4CK3R [Wed, 8 Feb 2023 06:44:42 +0000 (07:44 +0100)]
Map OIDC groups to Orgs/Teams (#21441)

Fixes #19555

Test-Instructions:
https://github.com/go-gitea/gitea/pull/21441#issuecomment-1419438000

This PR implements the mapping of user groups provided by OIDC providers
to orgs teams in Gitea. The main part is a refactoring of the existing
LDAP code to make it usable from different providers.

Refactorings:
- Moved the router auth code from module to service because of import
cycles
- Changed some model methods to take a `Context` parameter
- Moved the mapping code from LDAP to a common location

I've tested it with Keycloak but other providers should work too. The
JSON mapping format is the same as for LDAP.

![grafik](https://user-images.githubusercontent.com/1666336/195634392-3fc540fc-b229-4649-99ac-91ae8e19df2d.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix links for the menus in the view file page (#22795)
wxiaoguang [Tue, 7 Feb 2023 16:08:44 +0000 (00:08 +0800)]
Fix links for the menus in the view file page (#22795)

20 months agoFix restore repo bug, clarify the problem of ForeignIndex (#22776)
wxiaoguang [Tue, 7 Feb 2023 01:18:52 +0000 (09:18 +0800)]
Fix restore repo bug, clarify the problem of ForeignIndex (#22776)

Fix #22581

TLDR: #18446 made a mess with ForeignIndex and triggered a design
flaw/bug of #16356, then a quick patch #21271 helped #18446, then the
the bug was re-triggered by #21721 .

Related:
* #16356
* BasicIssueContext
https://github.com/go-gitea/gitea/pull/16356/files#diff-7938eb670d42a5ead6b08121e16aa4537a4d716c1cf37923c70470020fb9d036R16-R27
* #18446
* If some issues were dumped without ForeignIndex, then they would be
imported as ForeignIndex=0
https://github.com/go-gitea/gitea/pull/18446/files#diff-1624a3e715d8fc70edf2db1630642b7d6517f8c359cc69d58c3958b34ba4ce5eR38-R39
* #21271
* It patched the above bug (somewhat), made the issues without
ForeignIndex could have the same value as LocalIndex
* #21721
    * It re-triggered the zero-ForeignIndex bug.

ps: I am not sure whether the changes in `GetForeignIndex` are ideal (at
least, now it has almost the same behavior as BasicIssueContext in
#16356), it's just a quick fix. Feel free to edit on this PR directly or
replace it.

Co-authored-by: zeripath <art27@cantab.net>