]> source.dussan.org Git - gitea.git/log
gitea.git
20 months agoMatch api migration behavior to web behavior (#23552) (#23572) release/v1.18
Giteabot [Sun, 19 Mar 2023 07:29:57 +0000 (03:29 -0400)]
Match api migration behavior to web behavior (#23552) (#23572)

Backport #23552 by @atomaka

When attempting to migrate a repository via the API endpoint comments
are always included. This can create a problem if your source repository
has issues or pull requests but you do not want to import them into
Gitea that displays as something like:

> Error 500: We were unable to perform the request due to server-side
problems. 'comment references non existent IssueIndex 4

There are only two ways to resolve this:
1. Migrate using the web interface
2. Migrate using the API including at issues or pull requests.

This PR matches the behavior of the API migration router to the web
migration router.

Co-authored-by: Andrew Tomaka <atomaka@atomaka.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoHandle missing `README` in create repos API (#23387) (#23509)
Zettat123 [Fri, 17 Mar 2023 01:05:41 +0000 (09:05 +0800)]
Handle missing `README` in create repos API (#23387) (#23509)

Backport #23387
Close #22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.

20 months agoMake branches list page operations remember current page (#23420) (#23459)
Giteabot [Wed, 15 Mar 2023 12:13:27 +0000 (08:13 -0400)]
Make branches list page operations remember current page (#23420) (#23459)

Backport #23420 by @wxiaoguang

Close #23411

Always pass "page" query parameter to backend, and make backend respect
it.

The `ctx.FormInt("limit")` is never used, so removed.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
20 months agoFix due date being wrong on issue list (#23475) (#23479)
Yarden Shoham [Wed, 15 Mar 2023 01:41:09 +0000 (03:41 +0200)]
Fix due date being wrong on issue list (#23475) (#23479)

Backport #23475

Exactly like #22302 but in the issue list page

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoRedirect to the commit page after applying patch (#23056) & Fix commit name in Apply...
zeripath [Wed, 15 Mar 2023 00:06:02 +0000 (00:06 +0000)]
Redirect to the commit page after applying patch (#23056) & Fix commit name in Apply Patch page (#23086) (#23131)

Backport #23056
Backport #23086

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

Fixes
https://github.com/go-gitea/gitea/issues/22621#issuecomment-1439309200

Co-authored-by: yp05327 <576951401@qq.com>
20 months agoFix cannot reopen after pushing commits to a closed PR (#23189) (#23322) 23375/head
sillyguodong [Mon, 6 Mar 2023 17:38:45 +0000 (01:38 +0800)]
Fix cannot reopen after pushing commits to a closed PR (#23189) (#23322)

Backport: #23189
Close: #22784

1. On GH, we can reopen a PR which was closed before after pushing
commits. After reopening PR, we can see the commits that were pushed
after closing PR in the time line. So the case of
[issue](https://github.com/go-gitea/gitea/issues/22784) is a bug which
needs to be fixed.

2. After closing a PR and pushing commits, `headBranchSha` is not equal
to `sha`(which is the last commit ID string of reference). If the
judgement exists, the button of reopen will not display. So, skip the
judgement if the status of PR is closed.

![image](https://user-images.githubusercontent.com/33891828/222037529-651fccf9-0bba-433e-b2f0-79c17e0cc812.png)

3. Even if PR is already close, we should still insert comment record
into DB when we push commits.
So we should still call  function `CreatePushPullComment()`.

https://github.com/go-gitea/gitea/blob/067b0c2664d127c552ccdfd264257caca4907a77/services/pull/pull.go#L260-L282
So, I add a switch(`includeClosed`) to the
`GetUnmergedPullRequestsByHeadInfo` func to control whether the status
of PR must be open. In this case, by setting `includeClosed` to `true`,
we can query the closed PR.

![image](https://user-images.githubusercontent.com/33891828/222621045-bb80987c-10c5-4eac-aa0c-1fb9c6aefb51.png)

4. In the loop of comments, I use the`latestCloseCommentID` variable to
record the last occurrence of the close comment.
In the go template, if the status of PR is closed, the comments whose
type is `CommentTypePullRequestPush(29)` after `latestCloseCommentID`
won't be rendered.

![image](https://user-images.githubusercontent.com/33891828/222058913-c91cf3e3-819b-40c5-8015-654b31eeccff.png)
e.g.
1). The initial status of the PR is opened.

![image](https://user-images.githubusercontent.com/33891828/222453617-33c5093e-f712-4cd6-8489-9f87e2075869.png)
2). Then I click the button of `Close`. PR is closed now.

![image](https://user-images.githubusercontent.com/33891828/222453694-25c588a9-c121-4897-9ae5-0b13cf33d20b.png)
3). I try to push a commit to this PR, even though its current status is
closed.

![image](https://user-images.githubusercontent.com/33891828/222453916-361678fb-7321-410d-9e37-5a26e8095638.png)
But in comments list, this commit do not display.This is as expected :)

![image](https://user-images.githubusercontent.com/33891828/222454169-7617a791-78d2-404e-be5e-77d555f93313.png)
4). Click the `Reopen` button, the commit which is pushed after closing
PR display now.

![image](https://user-images.githubusercontent.com/33891828/222454533-897893b6-b96e-4701-b5cb-b1800f382b8f.png)

20 months agoChange interactiveBorder to fix popup preview (#23169) (#23313)
Giteabot [Mon, 6 Mar 2023 16:32:47 +0000 (11:32 -0500)]
Change interactiveBorder to fix popup preview  (#23169) (#23313)

Backport #23169

Close #23073.
Used the solution as reference to the reply:
https://github.com/go-gitea/gitea/issues/23073#issuecomment-1440124609
Here made the change inside the `contextpopup.js` because this is where
the popup component is created and tippy configuration is given.

Co-authored-by: Hester Gong <hestergong@gmail.com>
20 months agoProperly flush unique queues on startup (#23154) (#23200)
Giteabot [Mon, 6 Mar 2023 14:34:54 +0000 (09:34 -0500)]
Properly flush unique queues on startup (#23154) (#23200)

Backport #23154

There have been a number of reports of PRs being blocked whilst being
checked which have been difficult to debug. In investigating #23050 I
have realised that whilst the Warn there is somewhat of a miscall there
was a real bug in the way that the LevelUniqueQueue was being restored
on start-up of the PersistableChannelUniqueQueue.

Next there is a conflict in the setting of the internal leveldb queue
name - This wasn't being set so it was being overridden by other unique
queues.

This PR fixes these bugs and adds a testcase.

Thanks to @brechtvl  for noticing the second issue.

Fix #23050
and others

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <leon@kske.dev>
20 months agoAdd CLI option tenant ID for oauth2 source (#22769) (#23263)
Adi [Mon, 6 Mar 2023 10:20:07 +0000 (11:20 +0100)]
Add CLI option tenant ID for oauth2 source (#22769) (#23263)

Backport #22769

Fixes #22713

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFill head commit to in payload when notifying push commits for mirroring (#23215...
Giteabot [Sun, 5 Mar 2023 10:06:44 +0000 (05:06 -0500)]
Fill head commit to in payload when notifying push commits for mirroring (#23215) (#23291)

Backport #23215

Just like what has been done when pushing manually:

https://github.com/go-gitea/gitea/blob/7a5af25592003ddc3017fcd7b822a3e02fc40ef6/services/repository/push.go#L225-L226

Before:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100123-cd4839d1-2d4d-45f7-b7a0-0cbc73162b44.png">

After:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100225-f3c5bb65-7ab9-41e2-8e39-9d84c23c352d.png">

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoDo not create commit graph for temporary repos (#23219) (#23302)
zeripath [Sun, 5 Mar 2023 00:20:02 +0000 (00:20 +0000)]
Do not create commit graph for temporary repos (#23219)  (#23302)

Backport #23219

When fetching remotes for conflict checking, skip unnecessary and
potentially slow writing of commit graphs.

In a test with the Blender repository, this reduces conflict checking
time for one pull request from about 2s to 0.1s.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
20 months agoFix broken links in the Chinese docs (#23289)
anthony-zh [Sat, 4 Mar 2023 14:32:12 +0000 (22:32 +0800)]
Fix broken links in the Chinese docs (#23289)

When I used docusaurus to make Chinese documents, I found that there
were links on several Chinese pages with problems on docusaurus, so I
modified the links on some pages and removed some useless tags

---------

Co-authored-by: yeyuanjie <yecao100@126.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix GetFilesChangedBetween if the file name may be escaped (#23272) (#23278)
Giteabot [Sat, 4 Mar 2023 07:11:50 +0000 (02:11 -0500)]
Fix GetFilesChangedBetween if the file name may be escaped (#23272) (#23278)

Backport #23272

The code for GetFilesChangedBetween uses `git diff --name-only
base..head` to get the names of files changed between base and head
however this forgets that git will escape certain values.

This PR simply switches to use `-z` which has the `NUL` character as the
separator.

Ref https://github.com/go-gitea/gitea/pull/22568#discussion_r1123138096

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoUse the correct selector to hide the checkmark of selected labels on clear (#23224...
Giteabot [Wed, 1 Mar 2023 20:59:54 +0000 (15:59 -0500)]
Use the correct selector to hide the checkmark of selected labels on clear (#23224) (#23226)

Backport #23224

Regression of #10107
(https://github.com/go-gitea/gitea/pull/10107/files#diff-a15e36f2f9c13339f7fdd38bc2887db2ff2945cb8434464318ab9105fcc846bdR460)

Fix #22222

Before: the "clear" action couldn't remove these check marks.

![image](https://user-images.githubusercontent.com/2114189/222212998-c9f33459-b71d-4e80-8588-2935f3b7050c.png)

After: the "clear" action can remove these  check marks.

![image](https://user-images.githubusercontent.com/2114189/222213048-2be98ed0-cac0-4e27-b72c-1dd0ac2637d5.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 months agoChange button text for commenting and closing an issue at the same time (#23135)...
Yarden Shoham [Tue, 28 Feb 2023 22:54:38 +0000 (00:54 +0200)]
Change button text for commenting and closing an issue at the same time (#23135) (#23181)

Backport #23135

Close  #10468

Without SimpleMDE/EasyMDE, using Simple Textarea, the button text could
be changed when content changes.

After introducing SimpleMDE/EasyMDE, there is no code for updating the
button text.

![image](https://user-images.githubusercontent.com/2114189/221334034-8d556cd5-1136-4ba0-8faa-a65ffadd7fb7.png)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 months agoPass `--global` when calling `git config --get`, for consistency with `git config...
Giteabot [Tue, 28 Feb 2023 22:53:27 +0000 (17:53 -0500)]
Pass `--global` when calling `git config --get`, for consistency with `git config --set` (#23157) (#23198)

Backport #23157

This arose out of #22451; it seems we are checking using non-global
settings to see if a config value is set, in order to decide whether to
call another global(-indeed) configuration command. This PR changes it
so that both the check and the set are for global configuration.

Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
20 months agoMake `gitea serv` respect git binary home (#23138) (#23196)
Giteabot [Tue, 28 Feb 2023 22:46:27 +0000 (17:46 -0500)]
Make `gitea serv` respect git binary home (#23138) (#23196)

Backport #23138

Close #23137

The old code is too old (8-9 years ago)

Let's try to execute the git commands from git bin home directly.

The verb has been checked above, it could only be:
* git-upload-pack
* git-upload-archive
* git-receive-pack
* git-lfs-authenticate

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 months agoAdd word-break to sidebar-item-link (#23146) (#23179)
Yarden Shoham [Mon, 27 Feb 2023 21:30:06 +0000 (23:30 +0200)]
Add word-break to sidebar-item-link (#23146) (#23179)

Backport #23146

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

![image](https://user-images.githubusercontent.com/18380374/221351117-1e4b8922-04ca-4717-8e3b-c338a61bc062.png)

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: delvh <leon@kske.dev>
20 months agoAdd wrapper to author to avoid long name ui problem (#23030) (#23172)
HesterG [Mon, 27 Feb 2023 14:47:04 +0000 (22:47 +0800)]
Add wrapper to author to avoid long name ui problem (#23030) (#23172)

Backport #23030

This PR is a possible solution for issue #22866. Main change is to add a
`author-wrapper` class around author name, like the wrapper added to
message. The `max-width` is set to 200px on PC, and 100px on mobile
device for now. Which will work like below:

<img width="1183" alt="2023-02-21 11 57 53"
src="https://user-images.githubusercontent.com/17645053/220244146-3d47c512-33b6-4ed8-938e-de0a8bc26ffb.png">

<img width="417" alt="2023-02-21 11 58 43"
src="https://user-images.githubusercontent.com/17645053/220244154-1ea0476b-9d1c-473a-9917-d3216860f9a9.png">

And `title` is added to the wrapper like it did in message wrapper. So
the full author name will show on hover.

20 months agoFix DBConsistency checks on MSSQL (#23132) (#23133)
Yarden Shoham [Sat, 25 Feb 2023 19:17:14 +0000 (21:17 +0200)]
Fix DBConsistency checks on MSSQL (#23132) (#23133)

Backport #23132

Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
20 months agoFix height for sticky head on large screen on PR page (#23111) (#23124)
Yarden Shoham [Fri, 24 Feb 2023 16:35:59 +0000 (18:35 +0200)]
Fix height for sticky head on large screen on PR page (#23111) (#23124)

Backport #23111

Right now on the PR 'File Change' Tab, the file title header sticky to
the top on large screens has wrong height, resulting in wrong ui
behavior when scrolling down. This PR is to fix this.

Before:

<img width="964" alt="截屏2023-02-24 17 12 29"
src="https://user-images.githubusercontent.com/17645053/221140409-025c4a84-6bbe-4b5b-a13f-bd2b79063522.png">

After:
<img width="1430" alt="截屏2023-02-24 21 10 12"
src="https://user-images.githubusercontent.com/17645053/221186750-0344d652-4610-4a90-a4c0-7f6269f950d6.png">

---------

Co-authored-by: HesterG <hestergong@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
20 months agoChangelog 1.18.5 (#23045) v1.18.5
John Olheiser [Tue, 21 Feb 2023 18:14:55 +0000 (12:14 -0600)]
Changelog 1.18.5 (#23045)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
20 months agoReturn empty url for submodule tree entries (#23043) (#23048)
Yarden Shoham [Tue, 21 Feb 2023 17:35:14 +0000 (19:35 +0200)]
Return empty url for submodule tree entries (#23043) (#23048)

Backport #23043

Close #22614.

Refer to [Github's
API](https://docs.github.com/en/rest/git/trees?apiVersion=2022-11-28#get-a-tree),
if a tree entry is a submodule, its url will be an empty string.

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
20 months agoDisplay attachments of review comment when comment content is blank (#23035) (#23046)
John Olheiser [Tue, 21 Feb 2023 17:10:29 +0000 (11:10 -0600)]
Display attachments of review comment when comment content is blank (#23035) (#23046)

Backport #23035

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
20 months agoUse beforeCommit instead of baseCommit (#22949) (#22996)
Kyle D [Tue, 21 Feb 2023 15:51:02 +0000 (10:51 -0500)]
Use beforeCommit instead of baseCommit (#22949) (#22996)

Backport #22949
Fixes https://github.com/go-gitea/gitea/issues/22946
Probably related to https://github.com/go-gitea/gitea/issues/19530

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
21 months agoAdd force_merge to merge request and fix checking mergable (#23010) (#23032)
Jason Song [Tue, 21 Feb 2023 15:42:22 +0000 (23:42 +0800)]
Add force_merge to merge request and fix checking mergable (#23010) (#23032)

Backport #23010.

Fix #23000.

The bug was introduced in #22633, and it seems that it has been noticed:
https://github.com/go-gitea/gitea/pull/22633#discussion_r1095395359 .

However, #22633 did nothing wrong, the logic should be "check if they is
admin only when `force` is true".

So we should provide the `ForceMerge` when merging from UI.

After this, an admin can also send a normal merge request with
`ForceMerge` false. So it fixes a potential bug: if the admin doesn't
want to do a force merge, they just see the green "Merge" button and
click it. At the same time, the status of the PR changed, and it
shouldn't be merged now, so the admin could send an unexpected force
merge.

In addition, I updated `ForceMerge *bool` to `ForceMerge bool`, I don't
see the reason to use a pointer.

And fixed the logic of CheckPullMergable to handle auto merge and force
merge correctly.

21 months agoRender access log template as text instead of HTML (#23013) (#23025)
Yarden Shoham [Tue, 21 Feb 2023 10:04:57 +0000 (12:04 +0200)]
Render access log template as text instead of HTML (#23013) (#23025)

Backport #23013

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix the Manually Merged form (#23015) (#23017)
wxiaoguang [Tue, 21 Feb 2023 10:04:29 +0000 (18:04 +0800)]
Fix the Manually Merged form (#23015) (#23017)

Backport #23015

---------

Co-authored-by: Jason Song <i@wolfogre.com>
21 months ago Use `--message=%s` for git commit message (#23028) (#23029)
wxiaoguang [Tue, 21 Feb 2023 06:16:25 +0000 (14:16 +0800)]
 Use `--message=%s` for git commit message (#23028) (#23029)

Backport #23028

This backport is done by manually because the git module is different.

21 months agoHide 2FA status from other members in organization members list (#22999) (#23023)
Yarden Shoham [Tue, 21 Feb 2023 00:14:39 +0000 (02:14 +0200)]
Hide 2FA status from other members in organization members list (#22999) (#23023)

Backport #22999

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

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
21 months agoAdd 1.18.4 changelog (#22991) v1.18.4
Lunny Xiao [Mon, 20 Feb 2023 02:45:07 +0000 (10:45 +0800)]
Add 1.18.4 changelog (#22991)

Feel free to change the content. @go-gitea/maintainers

---------

Co-authored-by: delvh <dev.lh@web.de>
21 months agoProvide the ability to set password hash algorithm parameters (#22942) (#22943)
zeripath [Sun, 19 Feb 2023 07:35:52 +0000 (07:35 +0000)]
Provide the ability to set password hash algorithm parameters (#22942) (#22943)

Backport #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: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoNotify on container image create (#22806) (#22965)
Yarden Shoham [Sat, 18 Feb 2023 13:54:22 +0000 (15:54 +0200)]
Notify on container image create (#22806) (#22965)

Backport #22806

Fixes #22791

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix 404 error viewing the LFS file (#22945) (#22948)
Yarden Shoham [Fri, 17 Feb 2023 07:22:05 +0000 (09:22 +0200)]
Fix 404 error viewing the LFS file (#22945) (#22948)

Backport #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: Zettat123 <zettat123@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
21 months agoFix blame view missing lines (#22826) (#22929)
zeripath [Fri, 17 Feb 2023 02:19:24 +0000 (02:19 +0000)]
Fix blame view missing lines (#22826) (#22929)

Backport #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.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agosome refactor about code comments(#20821) (#22707)
Lunny Xiao [Thu, 16 Feb 2023 13:21:25 +0000 (21:21 +0800)]
some refactor about code comments(#20821) (#22707)

fix #22691
backport #20821

Co-authored-by: zeripath <art27@cantab.net>
21 months agoAdd command to bulk set must-change-password (#22823) (#22928)
zeripath [Thu, 16 Feb 2023 12:33:24 +0000 (12:33 +0000)]
Add command to bulk set must-change-password (#22823) (#22928)

Backport #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>
Co-authored-by: Jason Song <i@wolfogre.com>
21 months agofix incorrect role labels for migrated issues and comments (#22914) (#22923)
Yarden Shoham [Thu, 16 Feb 2023 03:19:46 +0000 (05:19 +0200)]
fix incorrect role labels for migrated issues and comments (#22914) (#22923)

Backport #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: Zettat123 <zettat123@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoImprove trace logging for pulls and processes (#22633) (#22812)
zeripath [Mon, 13 Feb 2023 03:17:36 +0000 (03:17 +0000)]
Improve trace logging for pulls and processes (#22633) (#22812)

Backport #22633

Our trace logging is far from perfect and is difficult to follow.

This PR:

* Add trace logging for process manager add and remove.
* Fixes an errant read file for git refs in getMergeCommit
* Brings in the pullrequest `String` and `ColorFormat` methods
introduced in #22568
* Adds a lot more logging in to testPR etc.

Ref #22578

---------
Signed-off-by: Andrew Thornton <art27@cantab.net>
21 months agoFix PR file tree folders no longer collapsing (#22864) (#22872)
Yarden Shoham [Sun, 12 Feb 2023 11:14:19 +0000 (13:14 +0200)]
Fix PR file tree folders no longer collapsing (#22864) (#22872)

Backport #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: gempir <daniel.pasch.s@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoescape filename when assemble URL (#22850) (#22871)
Yarden Shoham [Sun, 12 Feb 2023 09:39:52 +0000 (11:39 +0200)]
escape filename when assemble URL (#22850) (#22871)

Backport #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: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
21 months agoUse proxy for pull mirror (#22771) (#22772)
Gusted [Sat, 11 Feb 2023 08:11:54 +0000 (09:11 +0100)]
Use proxy for pull mirror (#22771) (#22772)

- Backport #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: zeripath <art27@cantab.net>
21 months agoFix isAllowed of escapeStreamer (#22814) (#22837)
Jason Song [Fri, 10 Feb 2023 03:36:58 +0000 (11:36 +0800)]
Fix isAllowed of escapeStreamer (#22814) (#22837)

Backport #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.

21 months agoLoad issue before accessing index in merge message (#22822) (#22830)
John Olheiser [Thu, 9 Feb 2023 21:53:14 +0000 (15:53 -0600)]
Load issue before accessing index in merge message (#22822) (#22830)

Backport #22822

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
21 months agoadd default user visibility to cli command "admin user create" (#22750) (#22760)
Yarden Shoham [Wed, 8 Feb 2023 17:04:38 +0000 (19:04 +0200)]
add default user visibility to cli command "admin user create" (#22750) (#22760)

Backport #22750

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

Co-authored-by: yp05327 <576951401@qq.com>
21 months agoFix color of tertiary button on dark theme (#22739) (#22744)
Yarden Shoham [Wed, 8 Feb 2023 15:44:40 +0000 (17:44 +0200)]
Fix color of tertiary button on dark theme (#22739) (#22744)

Backport #22739

Before:
<img width="266" alt="Screenshot 2023-02-03 at 14 07 34"
src="https://user-images.githubusercontent.com/115237/216611151-92e98305-c4b5-42f3-b2e2-8b1b805fa644.png">

After:
<img width="271" alt="Screenshot 2023-02-03 at 14 07 52"
src="https://user-images.githubusercontent.com/115237/216611156-878a8a75-39a1-415b-9b6d-4f035985444e.png">

This is the only instance of such a button in all templates.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix restore repo bug, clarify the problem of ForeignIndex (#22776) (#22794)
Yarden Shoham [Wed, 8 Feb 2023 08:39:42 +0000 (10:39 +0200)]
Fix restore repo bug, clarify the problem of ForeignIndex (#22776) (#22794)

Backport #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: wxiaoguang <wxiaoguang@gmail.com>
21 months agoUse import of OCI structs (#22765) (#22805)
KN4CK3R [Tue, 7 Feb 2023 23:50:19 +0000 (00:50 +0100)]
Use import of OCI structs (#22765) (#22805)

Backport of #22765

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
21 months agoupgrade golangcilint to v1.51.0 (#22764)
Lunny Xiao [Tue, 7 Feb 2023 19:28:25 +0000 (03:28 +0800)]
upgrade golangcilint to v1.51.0 (#22764)

With the upgrade to go 1.20 golangci-lint no longer correctly works. We must therefore upgrade to the latest golangci-lint.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
21 months agoEscape path for the file list (#22741) (#22757)
wxiaoguang [Mon, 6 Feb 2023 12:58:06 +0000 (20:58 +0800)]
Escape path for the file list (#22741) (#22757)

Backport #22741
Fix #22740

21 months agouse drone secrets for s3 config (#22770) (#22773)
Yarden Shoham [Sun, 5 Feb 2023 23:42:45 +0000 (01:42 +0200)]
use drone secrets for s3 config (#22770) (#22773)

21 months agoFix bugs with WebAuthn preventing sign in and registration. (#22651) (#22721)
zeripath [Thu, 2 Feb 2023 07:45:57 +0000 (07:45 +0000)]
Fix bugs with WebAuthn preventing sign in and registration. (#22651) (#22721)

Partial Backport #22651

This PR fixes a longstanding bug within webauthn due to the backend
using URLEncodedBase64 but the javascript using decoding using plain
base64. This causes intermittent issues with users reporting decoding
errors.

Fix #22507

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix line spacing for plaintext previews (#22699) (#22701)
crystal [Wed, 1 Feb 2023 22:06:58 +0000 (15:06 -0700)]
Fix line spacing for plaintext previews (#22699) (#22701)

Backport #22699

Adding `<br>` between each line is not necessary since the entire file
is rendered inside a `<pre>`

fixes https://codeberg.org/Codeberg/Community/issues/915

21 months agoAdd missing close bracket in imagediff (#22710) (#22712)
Yarden Shoham [Wed, 1 Feb 2023 12:30:52 +0000 (14:30 +0200)]
Add missing close bracket in imagediff (#22710) (#22712)

Backport #22710

There was a missing `]` in imagediff.js:

```
const $range = $container.find("input[type='range'");
```

This PR simply adds this.

Fix #22702

Co-authored-by: zeripath <art27@cantab.net>
21 months agoFix wrong hint when deleting a branch successfully from pull request UI (#22673)...
Yarden Shoham [Wed, 1 Feb 2023 01:35:38 +0000 (03:35 +0200)]
Fix wrong hint when deleting a branch successfully from pull request UI (#22673) (#22698)

Backport #22673

Fix #18785

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix README TOC links (#22577) (#22677)
crystal [Tue, 31 Jan 2023 09:23:19 +0000 (02:23 -0700)]
Fix README TOC links (#22577) (#22677)

Backport #22577

Fixes anchored markup links by adding `user-content-` (which is
prepended to IDs)

Closes https://codeberg.org/Codeberg/Community/issues/894

21 months agoDon't return duplicated users who can create org repo (#22560) (#22562)
Gusted [Mon, 30 Jan 2023 16:59:20 +0000 (17:59 +0100)]
Don't return duplicated users who can create org repo (#22560) (#22562)

- Backport of #22560
- Currently the function `GetUsersWhoCanCreateOrgRepo` uses a query that
is able to have duplicated users in the result, this is can happen under
the condition that a user is in team that either is the owner team or
has permission to create organization repositories.
- Add test code to simulate the above condition for user 3,
[`TestGetUsersWhoCanCreateOrgRepo`](https://github.com/go-gitea/gitea/blob/a1fcb1cfb84fd6b36c8fe9fd56588119fa4377bc/models/organization/org_test.go#L435)
is the test function that tests for this.
  - The fix is quite trivial, use a map as a set to get distinct orgs.

21 months agoFix missing message in git hook when pull requests disabled on fork (#22625) (#22658)
John Olheiser [Mon, 30 Jan 2023 00:55:45 +0000 (18:55 -0600)]
Fix missing message in git hook when pull requests disabled on fork (#22625) (#22658)

Backport #22625

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
21 months agoImprove checkIfPRContentChanged (#22611) (#22644)
zeripath [Sat, 28 Jan 2023 17:56:16 +0000 (17:56 +0000)]
Improve checkIfPRContentChanged (#22611) (#22644)

Backport #22611

The code for checking if a commit has caused a change in a PR is
extremely inefficient and affects the head repository instead of using a
temporary repository.

This PR therefore makes several significant improvements:

* A temporary repo like that used in merging.
* The diff code is then significant improved to use a three-way diff
instead of comparing diffs (possibly binary) line-by-line - in memory...

Ref #22578

Signed-off-by: Andrew Thornton <art27@cantab.net>
21 months agoLink issue and pull requests status change in UI notifications directly to their...
Yarden Shoham [Sat, 28 Jan 2023 15:51:00 +0000 (17:51 +0200)]
Link issue and pull requests status change in UI notifications directly to their event in the timelined view. (#22627) (#22642)

Backport #22627

Adding the related comment to the issue and pull request status change
in the UI notifications allows to navigate directly to the specific
event in its dedicated view, easing the reading of last comments and to
the editor for additional comments if desired.

Co-authored-by: Felipe Leopoldo Sologuren Gutiérrez <fsologureng@users.noreply.github.com>
21 months agoUse `--index-url` in PyPi description (#22620) (#22636)
Yarden Shoham [Sat, 28 Jan 2023 04:57:12 +0000 (06:57 +0200)]
Use `--index-url` in PyPi description (#22620) (#22636)

21 months agoPrevent duplicate labels when importing more than 99 (#22591) (#22598)
Yarden Shoham [Tue, 24 Jan 2023 20:48:21 +0000 (22:48 +0200)]
Prevent duplicate labels when importing more than 99 (#22591) (#22598)

Backport #22591

Importing labels (via `gitea restore-repo`) did not split them up into
batches properly. The first "batch" would create all labels, the second
"batch" would create all labels except those in the first "batch", etc.
This meant that when importing more than 99 labels (the batch size)
there would always be duplicate ones.

This is solved by actually passing `labels[:lbBatchSize]` to the
`CreateLabels()` function, instead of the entire list `labels`.

Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
21 months agoChangelog 1.18.3 (#22575) v1.18.3
John Olheiser [Mon, 23 Jan 2023 14:42:02 +0000 (08:42 -0600)]
Changelog 1.18.3 (#22575)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
21 months agoPrevent multiple `To` recipients (#22566) (#22569)
Yarden Shoham [Sun, 22 Jan 2023 17:37:26 +0000 (19:37 +0200)]
Prevent multiple `To` recipients (#22566) (#22569)

Backport #22566

Change the mailer interface to prevent the leaking of possible hidden
email addresses when sending to multiple recipients.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
22 months agoTruncate commit summary on repo files table. (#22551) (#22552)
Yarden Shoham [Fri, 20 Jan 2023 15:34:52 +0000 (17:34 +0200)]
Truncate commit summary on repo files table. (#22551) (#22552)

Backport #22551
There was an unintended regression in #21124 which assumed that
.commits-list .message-wrapper would only match the commit summaries on
/{owner}/{name}/commits/*. This assumption is incorrect as the
directory/file view also uses a .commits-list wrapper.

Rather than completely restructure this page this PR simply adjusts the
styling to again use display: inline-block; for #repo-files-table
.commit-list .message-wrapper

Fix #22360

22 months agoMute all links in issue timeline (#22534)
silverwind [Fri, 20 Jan 2023 05:18:58 +0000 (06:18 +0100)]
Mute all links in issue timeline (#22534)

Backport of https://github.com/go-gitea/gitea/pull/22533.
https://github.com/go-gitea/gitea/pull/21799 introduced a regression
where some links in the issue timeline were not muted any more. Fix it
by replacing all `class="text grey"` with `class="text grey
muted-links"` in the file.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoWhen updating by rebase we need to set the environment for head repo (#22535) (#22536) v1.18.2
zeripath [Thu, 19 Jan 2023 22:31:20 +0000 (22:31 +0000)]
When updating by rebase we need to set the environment for head repo (#22535) (#22536)

Backport #22535

The update by rebase code reuses the merge code but shortcircuits and
pushes back up to the head. However, it doesn't set the correct pushing
environment - and just uses the same environment as the base repo. This
leads to the push update failing and thence the PR becomes out-of-sync
with the head.

This PR fixes this and adjusts the trace logging elsewhere to help make
this clearer.

Fix #18802

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agochore: changelog 1.18.2 (#22530)
John Olheiser [Thu, 19 Jan 2023 20:23:25 +0000 (14:23 -0600)]
chore: changelog 1.18.2 (#22530)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoFix issue not auto-closing when it includes a reference to a branch (#22514) (#22521)
John Olheiser [Thu, 19 Jan 2023 17:17:44 +0000 (11:17 -0600)]
Fix issue not auto-closing when it includes a reference to a branch (#22514) (#22521)

Backport #22514

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agoFix invalid issue branch reference if not specified in template (#22513) (#22520)
John Olheiser [Thu, 19 Jan 2023 15:39:30 +0000 (09:39 -0600)]
Fix invalid issue branch reference if not specified in template (#22513) (#22520)

Backport #22513

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agocgo cross-compile for freebsd (#22397) (#22519)
techknowlogick [Thu, 19 Jan 2023 03:06:17 +0000 (22:06 -0500)]
cgo cross-compile for freebsd (#22397) (#22519)

Provide pre-compiled cgo binaries for freebsd

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
22 months ago Fix 500 error viewing pull request when fork has pull requests disabled (#22512...
John Olheiser [Wed, 18 Jan 2023 21:50:51 +0000 (15:50 -0600)]
 Fix 500 error viewing pull request when fork has pull requests disabled (#22512) (#22515)

Backport #22512

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agoReliable selection of admin user (#22509) (#22511)
John Olheiser [Wed, 18 Jan 2023 17:47:23 +0000 (11:47 -0600)]
Reliable selection of admin user (#22509) (#22511)

Backport #22509

Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
22 months agoSet disable_gravatar/enable_federated_avatar when offline mode is true (#22479) ...
Jason Song [Wed, 18 Jan 2023 16:30:34 +0000 (00:30 +0800)]
Set disable_gravatar/enable_federated_avatar when offline mode is true (#22479) (#22496)

Backport #22479.

When offline mode is true, we should set `disable_gravatar` to `true`
and `enable_federated_avatar` to `false` in system settings.

22 months agochore: changelog 1.18.1 (#22471) v1.18.1
John Olheiser [Tue, 17 Jan 2023 16:40:47 +0000 (10:40 -0600)]
chore: changelog 1.18.1 (#22471)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoUpdate `github.com/zeripath/zapx/v15` (#22485)
KN4CK3R [Tue, 17 Jan 2023 14:51:24 +0000 (15:51 +0100)]
Update `github.com/zeripath/zapx/v15` (#22485)

Fixes #22481

_Originally posted by @zeripath in
https://github.com/go-gitea/gitea/issues/22481#issuecomment-1385188703_

22 months agoFix pull request API field `closed_at` always being `null` (#22482) (#22483)
Yarden Shoham [Tue, 17 Jan 2023 11:41:43 +0000 (13:41 +0200)]
Fix pull request API field `closed_at` always being `null` (#22482) (#22483)

Backport #22482

Fix #22480

22 months agoFix migration from GitBucket (#22465)
Haruo Kinoshita [Tue, 17 Jan 2023 08:57:17 +0000 (17:57 +0900)]
Fix migration from GitBucket (#22465)

Migration from GitBucket does not work due to a access for "Reviews" API
on GitBucket that makes 404 response.
This PR has following changes.
1. Made to stop access for Reviews API while migrating from GitBucket.
2. Added support for custom URL (e.g.
`http://example.com/gitbucket/owner/repository`)
3. Made to accept for git checkout URL
(`http://example.com/git/owner/repository.git`)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoFix container blob mount (#22226) (#22476)
John Olheiser [Tue, 17 Jan 2023 06:50:45 +0000 (00:50 -0600)]
Fix container blob mount (#22226) (#22476)

Backport #22226

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoFix error when calculate the repository size (#22392) (#22474)
zeripath [Mon, 16 Jan 2023 22:07:06 +0000 (22:07 +0000)]
Fix error when calculate the repository size (#22392) (#22474)

Backport #22392

Fix #22386

`GetDirectorySize` moved as `getDirectorySize` because it becomes a
special function which should not be put in `util`.

Co-authored-by: Jason Song <i@wolfogre.com>
22 months agoFix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454...
zeripath [Mon, 16 Jan 2023 20:17:22 +0000 (20:17 +0000)]
Fix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454) (#22472)

Backport #22454

There is a mistake in the code for SearchRepositoryCondition where it
tests topics as a string. This is incorrect for postgres where topics is
cast and stored as json. topics needs to be cast to text for this to
work. (For some reason JSON_ARRAY_LENGTH does not work, so I have taken
the simplest solution of casting to text and doing a string comparison.)

Ref https://github.com/go-gitea/gitea/pull/21962#issuecomment-1379584057

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoFix environments for KaTeX and error reporting (#22453) (#22473)
zeripath [Mon, 16 Jan 2023 19:34:50 +0000 (19:34 +0000)]
Fix environments for KaTeX and error reporting (#22453) (#22473)

Backport #22453

In #22447 it was noticed that display environments were not working
correctly. This was due to the setting displayMode not being set.

Further it was noticed that the error was not being displayed correctly.

This PR fixes both of these issues by forcibly setting the displayMode
setting and corrects an error in displayError.

Fix #22447

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months ago Remove the netgo tag for Windows build (#22467) (#22468)
wxiaoguang [Mon, 16 Jan 2023 13:05:12 +0000 (21:05 +0800)]
 Remove the netgo tag for Windows build (#22467) (#22468)

Backport #22467

Fix #22370 and more.

Before Go 1.19, the `netgo` tag for Windows does nothing.

But Go 1.19 rewrite the net package code for Windows DNS, and there is a
bug:

* https://github.com/golang/go/issues/57757

This PR just removes the `netgo` tag for Windows build, then the Gitea
for Windows can have the old DNS behavior.

22 months agoFix leaving organization bug on user settings -> orgs (#21983) (#22438)
zeripath [Sun, 15 Jan 2023 23:29:27 +0000 (23:29 +0000)]
Fix leaving organization bug on user settings -> orgs (#21983) (#22438)

Backport #21983

Fix #21772

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 花墨 <shanee@live.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoRestore previous official review when an official review is deleted (#22449) (#22460)
Jimmy Praet [Sun, 15 Jan 2023 19:47:54 +0000 (20:47 +0100)]
Restore previous official review when an official review is deleted (#22449) (#22460)

Backport #22449

Co-authored-by: Lauris BH <lauris@nix.lv>
22 months agoPrevent panic on looking at api "git" endpoints for empty repos (#22457) (#22458)
zeripath [Sun, 15 Jan 2023 14:35:56 +0000 (14:35 +0000)]
Prevent panic on looking at api "git" endpoints for empty repos (#22457) (#22458)

Backport #22457

The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix #22452

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoFixed colour transparency regex matching in project board sorting (#22092) (#22437)
zeripath [Sun, 15 Jan 2023 12:05:04 +0000 (12:05 +0000)]
Fixed colour transparency regex matching in project board sorting (#22092) (#22437)

Backport #22092

As described in the linked issue (#22091), semi-transparent UI elements
would result in JS errors due to the fact that the CSS `backgroundColor`
element was being matched by the pattern
`^rgb\((\d+),\s*(\d+),\s*(\d+)\)$`, which does not take the alpha
channel into account.

I changed the pattern to `^rgba?\((\d+),\s*(\d+),\s*(\d+).*\)$`. This
new pattern accepts both `rgb` and `rgba` tuples, and ignores the alpha
channel (that little `.*` at the end) from the sorting criteria. The
reason why I chose to ignore alpha is because when it comes to kanban
colour sorting, only the hue is important; the order of the panels
should stay the same, even if some of them are transparent.

Alternative solutions were discussed in the bug report and are included
here for completeness:
1. Change the regex from ^rgb\((\d+),\s*(\d+),\s*(\d+)\)$ to
^rgba?\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d+(\.\d+)?))?\)$ (alpha channel is
a float or NaN on 5th group) and include the alpha channel in the
sorting criteria.
2. Rethink on why you're reading colours out of the CSS in the first
place, then reformat this sorting procedure.

Fix #22091

Co-authored-by: MisterCavespider <deler.urist@tutanota.de>
22 months agoLog STDERR of external renderer when it fails (#22442) (#22444)
Jonathan Tran [Sat, 14 Jan 2023 23:14:27 +0000 (18:14 -0500)]
Log STDERR of external renderer when it fails (#22442) (#22444)

Backport #22442.

22 months agofix: PR status layout on mobile (#21547) (#22441)
zeripath [Sat, 14 Jan 2023 08:56:44 +0000 (08:56 +0000)]
fix: PR status layout on mobile (#21547) (#22441)

Backport #21547

This PR fixes the layout of PR status layouts on mobile. For longer
status context names or on very small screens the text would overflow
and push the "Details" and "Required" badges out of the container.

Before:

![Screen Shot 2022-10-22 at 12 27

46](https://user-images.githubusercontent.com/13721712/197335454-e4decf09-4778-43e8-be88-9188fabbec23.png)

After:

![Screen Shot 2022-10-22 at 12 53

24](https://user-images.githubusercontent.com/13721712/197335449-2c731a6c-7fd6-4b97-be0e-704a99fd3d32.png)

Co-authored-by: kolaente <k@knt.li>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoFix wechatwork webhook sends empty content in PR review (#21762) (#22440)
zeripath [Sat, 14 Jan 2023 03:37:18 +0000 (03:37 +0000)]
Fix wechatwork webhook sends empty content in PR review (#21762) (#22440)

Backport #21762

Wechatwork webhook is sending the following string for pull request
reviews:

``` markdown
>
```

This commit fixes this problem.

Co-authored-by: Jim Kirisame <jim@lotlab.org>
22 months agoRemove duplicate "Actions" label in mobile view (#21974) (#22439)
zeripath [Fri, 13 Jan 2023 23:23:39 +0000 (23:23 +0000)]
Remove duplicate "Actions" label in mobile view (#21974) (#22439)

Backport #21974

Closes #21973.

The "Actions" button on the commit view page is labelled twice in mobile
view. No other buttons on the page have a `mobile-only` extra label, so
this PR removes it.

Before:

![before](https://user-images.githubusercontent.com/6496999/204540002-75baa08a-6c06-4b39-847b-34272e09d71e.PNG)

After:

![after](https://user-images.githubusercontent.com/6496999/204539991-a0607765-d5e2-4b1a-84c9-a3e16cbc674e.PNG)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Mark Ormesher <me@markormesher.co.uk>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
22 months agoPrepend refs/heads/ to issue template refs (#20461) (#22427)
zeripath [Fri, 13 Jan 2023 22:33:35 +0000 (22:33 +0000)]
Prepend refs/heads/ to issue template refs (#20461) (#22427)

Backport #20461

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoContinue GCing other repos on error in one repo (#22422) (#22425)
zeripath [Fri, 13 Jan 2023 21:29:16 +0000 (21:29 +0000)]
Continue GCing other repos on error in one repo (#22422) (#22425)

Backport #22422

The current code propagates all errors up to the iteration step meaning
that a single malformed repo will prevent GC of other repos.

This PR simply stops that propagation.

Fix #21605

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoCorrectly handle select on multiple channels in Queues (#22146) (#22428)
zeripath [Fri, 13 Jan 2023 20:42:42 +0000 (20:42 +0000)]
Correctly handle select on multiple channels in Queues (#22146) (#22428)

Backport #22146

There are a few places in FlushQueueWithContext which make an incorrect
assumption about how `select` on multiple channels works.

The problem is best expressed by looking at the following example:

```go
package main

import "fmt"

func main() {
    closedChan := make(chan struct{})
    close(closedChan)
    toClose := make(chan struct{})
    count := 0

    for {
        select {
        case <-closedChan:
            count++
            fmt.Println(count)
            if count == 2 {
                close(toClose)
            }
        case <-toClose:
            return
        }
    }
}
```

This PR double-checks that the contexts are closed outside of checking
if there is data in the dataChan. It also rationalises the WorkerPool
FlushWithContext because the previous implementation failed to handle
pausing correctly. This will probably fix the underlying problem in
 #22145

Fix #22145

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoRemove test session cache to reduce possible concurrent problem (#22199) (#22429)
Lunny Xiao [Fri, 13 Jan 2023 18:54:58 +0000 (02:54 +0800)]
Remove test session cache to reduce possible concurrent problem (#22199) (#22429)

backport #22199

22 months agoRestore function to "Show more" buttons (#22399) (#22426)
zeripath [Fri, 13 Jan 2023 09:29:10 +0000 (09:29 +0000)]
Restore function to "Show more" buttons (#22399) (#22426)

Backport #22399

There was a serious regression in #21012 which broke the Show More
button on the diff page, and the show more button was also broken on the
file tree too.

This PR fixes this by resetting the pageData.diffFiles as the vue
watched value and reattachs a function to the show more button outside
of the file tree view.

Fix #22380

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoAllow HOST has no port (#22280) (#22409)
Lunny Xiao [Thu, 12 Jan 2023 01:57:03 +0000 (09:57 +0800)]
Allow HOST has no port (#22280) (#22409)

Fix #22274
Backport #22280

This PR will allow `HOST` without port. Then a default port will be
given in future steps.

22 months agofix: omit avatar_url in discord payload when empty (#22393) (#22394)
John Olheiser [Tue, 10 Jan 2023 19:44:18 +0000 (13:44 -0600)]
fix: omit avatar_url in discord payload when empty (#22393) (#22394)

Backport #22393

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoDon't display stop watch top bar icon when disabled and hidden when click other place...
Yarden Shoham [Tue, 10 Jan 2023 09:21:29 +0000 (11:21 +0200)]
Don't display stop watch top bar icon when disabled and hidden when click other place (#22374) (#22387)

Backport #22374

Fix #22286

When timetracking is disabled, the stop watch top bar icon should be
hidden. When the stop watch recording popup, it should be allowed to
hide with some operation. Now click any place on this page will hide the
popup window.

22 months agoDon't lookup mail server when using sendmail (#22300) (#22383)
Lunny Xiao [Mon, 9 Jan 2023 17:18:03 +0000 (01:18 +0800)]
Don't lookup mail server when using sendmail (#22300) (#22383)

Fix #22287
backport #22300