]> source.dussan.org Git - gitea.git/log
gitea.git
7 months agoChange log for 1.21.7 (#29411) v1.21.7
Lunny Xiao [Mon, 26 Feb 2024 07:39:21 +0000 (15:39 +0800)]
Change log for 1.21.7 (#29411)

This is an emergency release to fix the bug #29402.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
7 months agoAdd missing space (#29393) (#29399)
Giteabot [Sun, 25 Feb 2024 16:08:44 +0000 (00:08 +0800)]
Add missing space (#29393) (#29399)

Backport #29393 by @KN4CK3R

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoenforce maxlength in frontend (#29389) (#29396)
Giteabot [Sun, 25 Feb 2024 14:56:44 +0000 (22:56 +0800)]
enforce maxlength in frontend (#29389) (#29396)

Backport #29389 by @zokkis

Set maxlength attribute in frontend

to long file-name

![image](https://github.com/go-gitea/gitea/assets/72873130/15111614-55ab-4583-acb2-15c25997601d)

![image](https://github.com/go-gitea/gitea/assets/72873130/4105ddd8-4973-4da8-b3ab-4cfae1b45554)
(same for branch-name and commit-summary)

Co-authored-by: Tim-Niclas Oelschläger <72873130+zokkis@users.noreply.github.com>
7 months agoUsers with `read` permission of pull requests can be assigned too (#27263) (#29372)
Giteabot [Sat, 24 Feb 2024 16:42:33 +0000 (00:42 +0800)]
Users with `read` permission of pull requests can be assigned too (#27263) (#29372)

Backport #27263 by @lunny

This PR will also keep the consistent between list assigned users and
check assigned users.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
7 months agoDo not double close reader (#29354) (#29370)
Giteabot [Sat, 24 Feb 2024 12:08:06 +0000 (20:08 +0800)]
Do not double close reader (#29354) (#29370)

Backport #29354 by @KN4CK3R

Fixes #29346

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
7 months agoDisplay friendly error message (#29105) (#29363)
Lunny Xiao [Sat, 24 Feb 2024 11:01:18 +0000 (19:01 +0800)]
Display friendly error message (#29105) (#29363)

Backport #29105

`ctx.Error` only displays the text but `ctx.ServerError` renders the
usual error page.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoDocker Tag Information in Docs (#29047) (#29362)
Lunny Xiao [Sat, 24 Feb 2024 10:41:10 +0000 (18:41 +0800)]
Docker Tag Information in Docs (#29047) (#29362)

Backport #29047

Add more details for the docker tag when using container registry.

Co-authored-by: wienans <40465543+wienans@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoFix validity of the FROM email address not being checked (#29347) (#29360)
Giteabot [Sat, 24 Feb 2024 08:23:21 +0000 (16:23 +0800)]
Fix validity of the FROM email address not being checked (#29347) (#29360)

Backport #29347 by @carlosfelgueiras

Fixes #27188.
Introduces a check on the installation that tries to parse the FROM
address. If it fails, shows a new error message to the user.

Co-authored-by: Carlos Felgueiras <carlosfelgueiras@tecnico.ulisboa.pt>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoFix project counter in organization/individual profile (#28068) (#29361)
Lunny Xiao [Sat, 24 Feb 2024 07:58:43 +0000 (15:58 +0800)]
Fix project counter in organization/individual profile (#28068) (#29361)

Fix #28052
Backport #28068
Before:

![image](https://github.com/go-gitea/gitea/assets/18380374/5f299983-4b38-4d68-ac0e-4be3c62c0558)

![image](https://github.com/go-gitea/gitea/assets/18380374/f0e12afd-483b-4882-80e9-0261beb3fe0c)

After:

![image](https://github.com/go-gitea/gitea/assets/18380374/47cccb7b-bb35-4a7d-9c5b-83133be0323a)

![image](https://github.com/go-gitea/gitea/assets/18380374/77825c0c-4bf2-4762-83a2-1a5a173cc22d)

Co-authored-by: yp05327 <576951401@qq.com>
7 months agoFix incorrect tests in 1.21 (#29366)
wxiaoguang [Sat, 24 Feb 2024 07:27:47 +0000 (15:27 +0800)]
Fix incorrect tests in 1.21 (#29366)

The submitted tests in the patch for the XSS fix is not right.

To test, it should test "what should happen", but not "what doesn't
exist" or "what is processed/decoded".

7 months agoFix tarball/zipball download bug (#29342) (#29352)
Giteabot [Fri, 23 Feb 2024 22:47:11 +0000 (06:47 +0800)]
Fix tarball/zipball download bug (#29342) (#29352)

Backport #29342 by @Zettat123

Fix #29249

~~Use the `/repos/{owner}/{repo}/archive/{archive}` API to download.~~

Apply #26430 to archive download URLs.

Co-authored-by: Zettat123 <zettat123@gmail.com>
7 months agoAdjust changelog for v1.21.6 to move prs to correct labels (#29339)
Lunny Xiao [Fri, 23 Feb 2024 07:46:56 +0000 (15:46 +0800)]
Adjust changelog for v1.21.6 to move prs to correct labels (#29339)

When releasing, the releaser should read all the pull requests carefully
and do some adjustments because some of pull requests' labels are not
right when it's merged.

And the changelog tool needs to be adjusted. If one pull request has
both `bug` and `API`, it should mark it as `bug` but not `API`.

7 months agoAdd Changelog v1.21.6 (#29335) v1.21.6
6543 [Thu, 22 Feb 2024 22:42:29 +0000 (23:42 +0100)]
Add Changelog v1.21.6 (#29335)

7 months agoFix XSS vulnerabilities (#29336)
6543 [Thu, 22 Feb 2024 22:37:21 +0000 (23:37 +0100)]
Fix XSS vulnerabilities (#29336)

- The Wiki page did not sanitize author name
- the reviewer name on a "dismiss review" comment is also affected
- the migration page has some spots

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-authored-by: jolheiser <john.olheiser@gmail.com>
7 months agoDon't show third-party JS errors in production builds (#29303) (#29333)
Giteabot [Thu, 22 Feb 2024 21:49:07 +0000 (05:49 +0800)]
Don't show third-party JS errors in production builds (#29303) (#29333)

Backport #29303 by @silverwind

So we don't get issues like
https://github.com/go-gitea/gitea/issues/29080 and
https://github.com/go-gitea/gitea/issues/29273 any more. Only active in
[production
builds](https://webpack.js.org/guides/production/#specify-the-mode), in
non-production the errors will still show.

Co-authored-by: silverwind <me@silverwind.io>
7 months agoRemove SSH workaround (#27893) (#29332)
6543 [Thu, 22 Feb 2024 20:45:31 +0000 (21:45 +0100)]
Remove SSH workaround (#27893) (#29332)

Backport #27893

- Update github.com/gliderlabs/ssh to include
https://github.com/gliderlabs/ssh/commit/02f9d573009f8c13755b6b90fa14a4f549b17b22.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1230

Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>
7 months agoOnly log error when tag sync fails (#29295) (#29327)
Giteabot [Thu, 22 Feb 2024 19:52:54 +0000 (03:52 +0800)]
Only log error when tag sync fails (#29295) (#29327)

Backport #29295 by @lunny

Fix #28843

This PR will bypass the pushUpdateTag to database failure when
syncAllTags. An error log will be recorded.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
7 months agoUse general token signing secret (#29205) (#29325)
wxiaoguang [Thu, 22 Feb 2024 17:07:41 +0000 (01:07 +0800)]
Use general token signing secret (#29205) (#29325)

Backport #29205 (including #29172)

Use a clearly defined "signing secret" for token signing.

7 months agoFix SSPI user creation (#28948) (#29323)
Lunny Xiao [Thu, 22 Feb 2024 16:42:14 +0000 (00:42 +0800)]
Fix SSPI user creation (#28948) (#29323)

Fixes #28945
Backport #28948

Setting the avatar is wrong and creating a random password is equal to
leave it empty.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoImprove the `issue_comment` workflow trigger event (#29277) (#29322)
Giteabot [Thu, 22 Feb 2024 16:19:48 +0000 (00:19 +0800)]
Improve the `issue_comment` workflow trigger event (#29277) (#29322)

Backport #29277 by @Zettat123

Fix #29175
Replace #29207

This PR makes some improvements to the `issue_comment` workflow trigger
event.

1. Fix the bug that pull requests cannot trigger `issue_comment`
workflows
2. Previously the `issue_comment` event only supported the `created`
activity type. This PR adds support for the missing `edited` and
`deleted` activity types.
3. Some events (including `issue_comment`, `issues`, etc. ) only trigger
workflows that belong to the workflow file on the default branch. This
PR introduces the `IsDefaultBranchWorkflow` function to check for these
events.

Co-authored-by: Zettat123 <zettat123@gmail.com>
7 months agoDiscard unread data of `git cat-file` (#29297) (#29310)
Giteabot [Thu, 22 Feb 2024 04:23:38 +0000 (12:23 +0800)]
Discard unread data of `git cat-file` (#29297) (#29310)

Backport #29297 by @KN4CK3R

Fixes #29101
Related #29298

Discard all read data to prevent misinterpreting existing data. Some
discard calls were missing in error cases.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: yp05327 <576951401@qq.com>
7 months agoImplement some action notifier functions (#29173) (#29308)
yp05327 [Thu, 22 Feb 2024 03:55:03 +0000 (12:55 +0900)]
Implement some action notifier functions (#29173) (#29308)

Backport #29173

Fix #29166

Add support for the following activity types of `pull_request`
- assigned
- unassigned
- review_requested
- review_request_removed
- milestoned
- demilestoned

7 months agoPrevent double use of `git cat-file` session. (#29298) (#29301)
KN4CK3R [Thu, 22 Feb 2024 03:20:20 +0000 (04:20 +0100)]
Prevent double use of `git cat-file` session. (#29298) (#29301)

Backport #29298
Fixes the reason why #29101 is hard to replicate.
Related #29297

Create a repo with a file with minimum size 4097 bytes (I use 10000) and
execute the following code:
```go
gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, <repo>)
assert.NoError(t, err)

commit, err := gitRepo.GetCommit(<sha>)
assert.NoError(t, err)

entry, err := commit.GetTreeEntryByPath(<file>)
assert.NoError(t, err)

b := entry.Blob()

// Create a reader
r, err := b.DataAsync()
assert.NoError(t, err)
defer r.Close()

// Create a second reader
r2, err := b.DataAsync()
assert.NoError(t, err) // Should be no error but is ErrNotExist
defer r2.Close()
```

The problem is the check in `CatFileBatch`:

https://github.com/go-gitea/gitea/blob/79217ea63c1f77de7ca79813ae45950724e63d02/modules/git/repo_base_nogogit.go#L81-L87
`Buffered() > 0` is used to check if there is a "operation" in progress
at the moment. This is a problem because we can't control the internal
buffer in the `bufio.Reader`. The code above demonstrates a sequence
which initiates an operation for which the code thinks there is no
active processing. The second call to `DataAsync()` therefore reuses the
existing instances instead of creating a new batch reader.

7 months agoFix gitea-action user avatar broken on edited menu (#29190) (#29307)
yp05327 [Thu, 22 Feb 2024 02:53:38 +0000 (11:53 +0900)]
Fix gitea-action user avatar broken on edited menu (#29190) (#29307)

Backport #29190

Fix #29178

7 months agoFix error display when merging PRs (#29288) (#29309)
Zettat123 [Thu, 22 Feb 2024 02:32:54 +0000 (10:32 +0800)]
Fix error display when merging PRs (#29288) (#29309)

Backport #29288
Partially fix #29071, regression of Modernize merge button #28140

Fix some missing `Redirect` -> `JSONRedirect`.

Thanks @yp05327 for the help in
https://github.com/go-gitea/gitea/issues/29071#issuecomment-1931261075

7 months agoFix missing link on outgoing new release notifications (#29079) (#29300)
wxiaoguang [Wed, 21 Feb 2024 19:01:48 +0000 (03:01 +0800)]
Fix missing link on outgoing new release notifications (#29079) (#29300)

Backport #29079

Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
Co-authored-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoFix debian InRelease Acquire-By-Hash newline (#29204) (#29299)
wxiaoguang [Wed, 21 Feb 2024 18:40:16 +0000 (02:40 +0800)]
Fix debian InRelease Acquire-By-Hash newline (#29204) (#29299)

Backport #29204

Co-authored-by: Robin Schoonover <robin@cornhooves.org>
7 months agoAlways write proc-receive hook for all git versions (#29287) (#29291)
wxiaoguang [Wed, 21 Feb 2024 11:08:34 +0000 (19:08 +0800)]
Always write proc-receive hook for all git versions (#29287) (#29291)

Backport #29287

7 months agoDo not show delete button when time tracker is disabled (#29257) (#29279)
Zettat123 [Tue, 20 Feb 2024 09:11:01 +0000 (17:11 +0800)]
Do not show delete button when time tracker is disabled (#29257) (#29279)

Backport #29257
Fix #29233

The delete button of time logs won't be shown when the time tracker is
disabled.

![image](https://github.com/go-gitea/gitea/assets/15528715/5cc4e0c9-d2f9-4b8f-a2f5-fe202b94c191)

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agoFix missed edit issues event for actions (#29237) (#29251)
Lunny Xiao [Tue, 20 Feb 2024 03:13:05 +0000 (11:13 +0800)]
Fix missed edit issues event for actions (#29237) (#29251)

Fix #29213
Backport #29237

7 months agoDisallow merge when required checked are missing (#29143) (#29268)
Markus Amshove [Mon, 19 Feb 2024 20:48:17 +0000 (21:48 +0100)]
Disallow merge when required checked are missing (#29143) (#29268)

backport #29143

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
7 months agoWorkaround to clean up old reviews on creating a new one (#28554) (#29264)
6543 [Mon, 19 Feb 2024 16:48:58 +0000 (17:48 +0100)]
Workaround to clean up old reviews on creating a new one (#28554) (#29264)

close  #28542
backport #28554

---
*Sponsored by Kithara Software GmbH*

7 months agoFix bug when the linked account was disactived and list the linked accounts (#29263)
Lunny Xiao [Mon, 19 Feb 2024 15:23:47 +0000 (23:23 +0800)]
Fix bug when the linked account was disactived and list the linked accounts (#29263)

The bug has been fixed on v1.22 but not backport to v1.21.
This original PR have many refactors so I don't think it's necessary to
backport all of them.

Fix #28667

7 months agoExplained where create issue/PR template (#29035)
Km [Mon, 19 Feb 2024 14:57:25 +0000 (15:57 +0100)]
Explained where create issue/PR template (#29035)

For some user (as me), documentation lack of precision about where to
store issue/pr template.

I propose an enhancement about this point. With bold exergue and
precision about server itself.

I've found some user with same interrogation as :
https://forum.gitea.com/t/issue-template-directory/3328

---------

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
7 months agoDo not use lower tag names to find releases/tags (#29261) (#29262)
Jason Song [Mon, 19 Feb 2024 10:09:36 +0000 (18:09 +0800)]
Do not use lower tag names to find releases/tags (#29261) (#29262)

Backport #29261.

Fix #26090, see
https://github.com/go-gitea/gitea/issues/26090#issuecomment-1952013206

Since `TagName` stores the original tag name and `LowerTagName` stores
the lower tag name, it doesn't make sense to use lowercase tags as
`TagNames` in `FindReleasesOptions`.

https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/services/repository/push.go#L396-L397

While the only other usage looks correct:

https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/routers/web/repo/repo.go#L416

7 months agoConvert visibility to number (#29226) (#29244)
Tim-Nicas Oelschläger [Sun, 18 Feb 2024 18:51:00 +0000 (19:51 +0100)]
Convert visibility to number (#29226) (#29244)

Backport #29226

Don't throw error while creating user (Fixes #29218)

---

The backport info from Giteabot
https://github.com/go-gitea/gitea/pull/29226#issuecomment-1951341322
needs to specify the version, because the default is v1.18

7 months agoLoad outdated comments when (un)resolving conversation on PR timeline (#29203) (...
Jimmy Praet [Sun, 18 Feb 2024 06:58:26 +0000 (07:58 +0100)]
Load outdated comments when (un)resolving conversation on PR timeline (#29203) (#29221)

Backport #29203

Relates to #28654, #29039 and #29050.

The "show outdated comments" flag should only apply to the file diff
view.
On the PR timeline, outdated comments are always shown. So they should
also be loaded when (un)resolving a conversation on the timeline page.

7 months agoMake submit event code work with both jQuery event and native event (#29223) (#29234)
wxiaoguang [Sun, 18 Feb 2024 06:36:41 +0000 (14:36 +0800)]
Make submit event code work with both jQuery event and native event (#29223) (#29234)

Backport #29223 (no conflict)

7 months agoOnly delete scheduled workflows when needed (#29091) (#29235)
Zettat123 [Sun, 18 Feb 2024 06:31:05 +0000 (14:31 +0800)]
Only delete scheduled workflows when needed (#29091) (#29235)

Backport #29091

Fix #29040

`handleSchedules` should be called only if `DetectWorkflows` should
detect schedule workflows

7 months agoFix push to create with capitalize repo name (#29090) (#29206)
Lunny Xiao [Sat, 17 Feb 2024 12:06:55 +0000 (20:06 +0800)]
Fix push to create with capitalize repo name (#29090) (#29206)

Fix #29073
Backport #29090

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
7 months agorm outdated docs from some languages (#27530) (#29208)
Lunny Xiao [Sat, 17 Feb 2024 11:44:33 +0000 (19:44 +0800)]
rm outdated docs from some languages (#27530) (#29208)

backport #27530 to make pull request lint happy
https://github.com/go-gitea/gitea/actions/runs/7939560756/job/21679856929?pr=29206
since #29106

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.com>
7 months agoRefactor git version functions and check compatibility (#29155) (#29157)
wxiaoguang [Sat, 17 Feb 2024 02:47:18 +0000 (10:47 +0800)]
Refactor git version functions and check compatibility (#29155) (#29157)

Backport #29155 with an extra change: tolerate the git 2.43.1 GIT_FLUSH
bug in Gitea 1.21.x, more details in the comment of repo_attribute.go

Manually tested with git 2.43.1 and an old git (2.39.2)

7 months agoRework spellchecking, add lint-spell (#29112)
silverwind [Fri, 16 Feb 2024 02:42:26 +0000 (03:42 +0100)]
Rework spellchecking, add lint-spell (#29112)

Backport clean cherry-picks of
https://github.com/go-gitea/gitea/commit/9c39f8515fa88d644736c6773d7a05d070a02e82
and
https://github.com/go-gitea/gitea/commit/c7a21cbb0c5f8302495fa24baf218dc3462de2c5
onto 1.21.

- Use maintained fork https://github.com/golangci/misspell
- Rename `mispell-check` to `lint-spell`, add `lint-spell-fix`
- Run `lint-spell` in separate actions step
- Lint more files, fix discovered issues
- Remove inaccurate and outdated info in docs (we do not need GOPATH for
tools anymore)

Maybe later we can add more spellchecking tools, but I have not found
any good ones yet.

8 months agoUse ghost user if user was not found (#29161) (#29169)
KN4CK3R [Wed, 14 Feb 2024 17:51:51 +0000 (18:51 +0100)]
Use ghost user if user was not found (#29161) (#29169)

Backport #29161

8 months agoRefactor issue template parsing and fix API endpoint (#29069) (#29140)
wxiaoguang [Wed, 14 Feb 2024 01:32:31 +0000 (09:32 +0800)]
Refactor issue template parsing and fix API endpoint (#29069) (#29140)

Backport #29069

The old code `GetTemplatesFromDefaultBranch(...) ([]*api.IssueTemplate,
map[string]error)` doesn't really follow Golang's habits, then the
second returned value might be misused. For example, the API function
`GetIssueTemplates` incorrectly checked the second returned value and
always responds 500 error.

This PR refactors GetTemplatesFromDefaultBranch to
ParseTemplatesFromDefaultBranch and clarifies its behavior, and fixes
the API endpoint bug, and adds some tests.

And by the way, add proper prefix `X-` for the header generated in
`checkDeprecatedAuthMethods`, because non-standard HTTP headers should
have `X-` prefix, and it is also consistent with the new code in
`GetIssueTemplates`

8 months agoDont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160)
6543 [Tue, 13 Feb 2024 22:29:33 +0000 (23:29 +0100)]
Dont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160)

Backport #28551

RequestReview get deleted on review.
So we don't have to try to load them on comments.

8 months agoRefactor parseSignatureFromCommitLine (#29054) (#29108)
wxiaoguang [Fri, 9 Feb 2024 09:26:43 +0000 (17:26 +0800)]
Refactor parseSignatureFromCommitLine (#29054) (#29108)

Backport #29054. Fix #28840

This backport is for 1.21 only and it is different from the change in
1.22: this backport still accept the legacy date format to avoid
breaking.

8 months agoFix swift packages not resolving (#29095) (#29102)
CEnnis91 [Thu, 8 Feb 2024 18:26:54 +0000 (13:26 -0500)]
Fix swift packages not resolving (#29095) (#29102)

8 months agoFix incorrect link to swift doc and swift package-registry login command (#29096...
CEnnis91 [Thu, 8 Feb 2024 18:05:10 +0000 (13:05 -0500)]
Fix incorrect link to swift doc and swift package-registry login command (#29096) (#29103)

8 months agoAvoid showing unnecessary JS errors when there are elements with different origin...
Giteabot [Thu, 8 Feb 2024 02:48:06 +0000 (10:48 +0800)]
Avoid showing unnecessary JS errors when there are elements with different origin on the page (#29081) (#29089)

Backport #29081 by wxiaoguang

Try to fix #29080

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
8 months agoFix gitea-origin-url with default ports (#29085) (#29088)
Giteabot [Thu, 8 Feb 2024 02:41:49 +0000 (10:41 +0800)]
Fix gitea-origin-url with default ports (#29085) (#29088)

Backport #29085 by @silverwind

When setting `url.host` on a URL object with no port specified (like is
the case of default port), the resulting URL's port will not change.
Workaround this quirk in the URL standard by explicitely setting port
for the http and https protocols.

Extracted the logic to a function for the purpose of testing. Initially
I wanted to have the function in utils.js, but it turns out esbuild can
not treeshake the unused functions which would result in the
webcomponents chunk having all 2kB utils.js inlined, so it seemed not
worth.

Fixes: https://github.com/go-gitea/gitea/issues/29084
Co-authored-by: silverwind <me@silverwind.io>
8 months agoImprove user experience for outdated comments (#29050) (#29086)
Giteabot [Thu, 8 Feb 2024 02:29:54 +0000 (10:29 +0800)]
Improve user experience for outdated comments (#29050) (#29086)

Backport #29050 by wxiaoguang

Try to improve #28949

1. Make `ctx.Data["ShowOutdatedComments"] = true` by default: it brings
consistent user experience, and sometimes the "outdated (source
changed)" comments are still valuable.
2. Show a friendly message if the comment won't show, then the end users
won't fell that "the comment disappears" (it is the special case when
`ShowOutdatedComments = false`)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
8 months agoFix orgmode link resolving (#29024) (#29076)
wxiaoguang [Wed, 7 Feb 2024 17:24:28 +0000 (01:24 +0800)]
Fix orgmode link resolving (#29024) (#29076)

Backport #29024
Also backport #27968 (remove unnecessary titles)

Fix #28974

Add some new tests and fix some legacy unclear tests.

8 months agofix: Elasticsearch: Request Entity Too Large #28117 (#29062) (#29075)
Giteabot [Wed, 7 Feb 2024 09:21:28 +0000 (17:21 +0800)]
fix: Elasticsearch: Request Entity Too Large #28117 (#29062) (#29075)

Backport #29062 by @inferno-umar

Fix for gitea putting everything into one request without batching and
sending it to Elasticsearch for indexing as issued in #28117

This issue occured in large repositories while Gitea tries to
index the code using ElasticSearch.

Co-authored-by: dark-angel <70754989+inferno-umar@users.noreply.github.com>
8 months agoHide code links on release page if user cannot read code (#29064) (#29066)
Giteabot [Tue, 6 Feb 2024 13:36:56 +0000 (21:36 +0800)]
Hide code links on release page if user cannot read code (#29064) (#29066)

Backport #29064 by @wolfogre

On the release list page, if the user doesn't have the permission to
read code, the code links will lead to 404 pages or api errors:

<img width="1297" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/a74fbc63-6dd6-43c6-853c-28acdbfdcb4e">

After this PR:

<img width="1297" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/a626373d-c2df-40a9-8fed-1b12ff6bc56f">

And this PR also removed some dead code. After #23465, the tag list page
has an independent template, and all `IsTag` in the release list
template are always false.

Co-authored-by: Jason Song <i@wolfogre.com>
8 months agoFix typos in the documentation (#29048) (#29056)
Wang [Mon, 5 Feb 2024 13:15:49 +0000 (21:15 +0800)]
Fix typos in the documentation (#29048) (#29056)

Backport #29048

Corrected two typos.

8 months agoDo not render empty comments (#29039) (#29049)
Giteabot [Sun, 4 Feb 2024 13:25:58 +0000 (21:25 +0800)]
Do not render empty comments (#29039) (#29049)

Backport #29039 by wxiaoguang

Follow #28654

The `comments` might be empty, so the templates shouldn't (and couldn't)
use it to render. When there is no comment, the UI should also be
updated to empty, so returning an empty body is good enough.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
8 months agolabels and licenses are directories (#29037)
Km [Sat, 3 Feb 2024 23:11:41 +0000 (00:11 +0100)]
labels and licenses are directories (#29037)

Be more explicit about custom path relative to licences and labels
content

8 months agoAvoid sending update/delete release notice when it is draft (#29008) (#29025)
Giteabot [Fri, 2 Feb 2024 09:37:37 +0000 (17:37 +0800)]
Avoid sending update/delete release notice when it is draft (#29008) (#29025)

Backport #29008 by @yp05327

Fix #27157

Co-authored-by: yp05327 <576951401@qq.com>
8 months agoWrap contained tags and branches again (#29021) (#29026)
Giteabot [Fri, 2 Feb 2024 08:05:47 +0000 (16:05 +0800)]
Wrap contained tags and branches again (#29021) (#29026)

Backport #29021 by @delvh

Fixes #29016

## After

![grafik](https://github.com/go-gitea/gitea/assets/51889757/2c72ee8f-439e-4328-85df-77772e0f4aef)

Co-authored-by: delvh <dev.lh@web.de>
8 months agoFix incorrect button CSS usages (#29015) (#29023)
Giteabot [Fri, 2 Feb 2024 00:10:23 +0000 (08:10 +0800)]
Fix incorrect button CSS usages (#29015) (#29023)

Backport #29015 by @wxiaoguang

Fix 2 problems:

1. Remove the legacy (non-existing) CSS: `class="btn btn-gray
btn-radius"`
2. Remove the button styles inside the `ui message`, according to:
https://fomantic-ui.com/collections/message.html , the button shouldn't
have any border/padding.

### Before

![image](https://github.com/go-gitea/gitea/assets/2114189/4c7e98e2-4e8a-493f-9b7e-446a365066a1)

![image](https://github.com/go-gitea/gitea/assets/2114189/05221251-7a79-4c96-8973-fb4588275672)

### After

![image](https://github.com/go-gitea/gitea/assets/2114189/8bc3edbc-42a6-40bd-85fd-de40e94841d4)

![image](https://github.com/go-gitea/gitea/assets/2114189/93f69143-d835-437c-b5eb-0f6dddde97a1)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
8 months agoStrip trailing newline in markdown code copy (#29019) (#29022)
Giteabot [Thu, 1 Feb 2024 21:06:21 +0000 (05:06 +0800)]
Strip trailing newline in markdown code copy (#29019) (#29022)

Behaviour now matches GH. Safeguard added in the for loop because
`textContent` may be null in which case it does not make sense to render
the copy button.

Co-authored-by: silverwind <me@silverwind.io>
8 months agoAdd changelog for 1.21.5 (#28992) v1.21.5
Lunny Xiao [Thu, 1 Feb 2024 11:02:41 +0000 (19:02 +0800)]
Add changelog for 1.21.5 (#28992)

As title.

8 months agoRevert "Speed up loading the dashboard on mysql/mariadb (#28546)" (#29006) (#29007)
Giteabot [Thu, 1 Feb 2024 10:58:44 +0000 (18:58 +0800)]
Revert "Speed up loading the dashboard on mysql/mariadb (#28546)" (#29006) (#29007)

Backport #29006 by @lunny

This reverts commit fa8c3beb26acfcc7e732038c947225857ebcbf31. #28546
Because it seems performance become worse.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoFix an actions schedule bug (#28942) (#28999)
Giteabot [Wed, 31 Jan 2024 15:52:31 +0000 (23:52 +0800)]
Fix an actions schedule bug (#28942) (#28999)

Backport #28942 by @Zettat123

In #28691, schedule plans will be deleted when a repo's actions unit is
disabled. But when the unit is enabled, the schedule plans won't be
created again.

This PR fixes the bug. The schedule plans will be created again when the
actions unit is re-enabled

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoDon't remove all mirror repository's releases when mirroring (#28817) (#28939)
Giteabot [Wed, 31 Jan 2024 04:23:26 +0000 (12:23 +0800)]
Don't remove all mirror repository's releases when mirroring (#28817) (#28939)

Backport #28817 by @lunny

Fix #22066

# Purpose

This PR fix the releases will be deleted when mirror repository sync the
tags.

# The problem

In the previous implementation of #19125. All releases record in
databases of one mirror repository will be deleted before sync.
Ref:
https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481

# The Pros

This PR introduced a new method which will load all releases from
databases and all tags on git data into memory. And detect which tags
needs to be inserted, which tags need to be updated or deleted. Only
tags releases(IsTag=true) which are not included in git data will be
deleted, only tags which sha1 changed will be updated. So it will not
delete any real releases include drafts.

# The Cons

The drawback is the memory usage will be higher than before if there are
many tags on this repository. This PR defined a special release struct
to reduce columns loaded from database to memory.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoPreserve BOM in web editor (#28935) (#28959)
Giteabot [Sat, 27 Jan 2024 22:23:31 +0000 (06:23 +0800)]
Preserve BOM in web editor (#28935) (#28959)

Backport #28935 by @silverwind

The `ToUTF8*` functions were stripping BOM, while BOM is actually valid
in UTF8, so the stripping must be optional depending on use case. This
does:

- Add a options struct to all `ToUTF8*` functions, that by default will
strip BOM to preserve existing behaviour
- Remove `ToUTF8` function, it was dead code
- Rename `ToUTF8WithErr` to `ToUTF8`
- Preserve BOM in Monaco Editor
- Remove a unnecessary newline in the textarea value. Browsers did
ignore it, it seems but it's better not to rely on this behaviour.

Fixes: https://github.com/go-gitea/gitea/issues/28743
Related: https://github.com/go-gitea/gitea/issues/6716 which seems to
have once introduced a mechanism that strips and re-adds the BOM, but
from what I can tell, this mechanism was removed at some point after
that PR.

Co-authored-by: silverwind <me@silverwind.io>
8 months agoStrip `/` from relative links (#28932) (#28952)
Giteabot [Sat, 27 Jan 2024 15:14:36 +0000 (23:14 +0800)]
Strip `/` from relative links (#28932) (#28952)

Backport #28932 by @KN4CK3R

Fixes #28915

Restores the old behaviour:

https://github.com/go-gitea/gitea/pull/26745/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59L96

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
8 months agoMake loading animation less aggressive (#28955) (#28956)
Giteabot [Sat, 27 Jan 2024 12:38:14 +0000 (20:38 +0800)]
Make loading animation less aggressive (#28955) (#28956)

Backport #28955 by @yardenshoham

The current animation loops in a very fast manner, causing a slight
feeling of uncomfortableness. This change slows it a bit for a smoother
experience.

# Before

![before](https://github.com/go-gitea/gitea/assets/20454870/215a722d-feb4-4643-819d-c37a620c5e48)

# After

![after](https://github.com/go-gitea/gitea/assets/20454870/7acb1fab-9157-4f4d-8cc7-45fea0234b47)

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: Yarden Shoham <git@yardenshoham.com>
8 months agoUpdate go dependencies and fix go-git (#28893) (#28934)
6543 [Fri, 26 Jan 2024 07:08:43 +0000 (08:08 +0100)]
Update go dependencies and fix go-git (#28893) (#28934)

Backport #28893

8 months agofix: update enable_prune even if mirror_interval is not provided (#28905) (#28929)
Giteabot [Thu, 25 Jan 2024 23:14:38 +0000 (07:14 +0800)]
fix: update enable_prune even if mirror_interval is not provided (#28905) (#28929)

Backport #28905 by @Anthony-Jhoiro

Currently, the `updateMirror` function which update the mirror interval
and enable prune properties is only executed by the `Edit` function. But
it is only triggered if `opts.MirrorInterval` is not null, even if
`opts.EnablePrune` is not null.

With this patch, it is now possible to update the enable_prune property
with a patch request without modifying the mirror_interval.

## Example request with httpie

### Currently:
**Does nothing**
```bash
http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" -A bearer -a $gitea_token
```

**Updates both properties**
```bash
http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" "mirror_interval=10m" -A bearer -a $gitea_token
```

### With the patch
**Updates enable_prune only**
```bash
http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" -A bearer -a $gitea_token
```

Co-authored-by: Anthony Quéré <47711333+Anthony-Jhoiro@users.noreply.github.com>
8 months agoImplement `MigrateRepository` for the actions notifier (#28920) (#28923)
Giteabot [Thu, 25 Jan 2024 12:27:11 +0000 (20:27 +0800)]
Implement `MigrateRepository` for the actions notifier (#28920) (#28923)

Backport #28920 by @Zettat123

Fixes #28699

This PR implements the `MigrateRepository` method for `actionsNotifier`
to detect the schedules from the workflow files in the migrated
repository.

Co-authored-by: Zettat123 <zettat123@gmail.com>
8 months agoRespect branch info for relative links (#28909) (#28922)
Giteabot [Thu, 25 Jan 2024 09:40:29 +0000 (17:40 +0800)]
Respect branch info for relative links (#28909) (#28922)

Backport #28909 by @KN4CK3R

Fix #28904

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
8 months agoUpgrade xorm to v1.3.7 to fix a resource leak problem caused by Iterate (#28891)...
Lunny Xiao [Thu, 25 Jan 2024 03:12:11 +0000 (11:12 +0800)]
Upgrade xorm to v1.3.7 to fix a resource leak problem caused by Iterate (#28891) (#28895)

backport #28891

Mainly fix an error https://gitea.com/xorm/xorm/issues/2393

8 months agoDon't reload timeline page when (un)resolving or replying conversation (#28654) ...
Jimmy Praet [Wed, 24 Jan 2024 19:09:48 +0000 (20:09 +0100)]
Don't reload timeline page when (un)resolving or replying conversation (#28654) (#28917)

Backport #28654
Fixes #15981

8 months agoOnly migrate the first 255 chars of a Github issue title (#28902) (#28912)
Giteabot [Wed, 24 Jan 2024 11:56:54 +0000 (19:56 +0800)]
Only migrate the first 255 chars of a Github issue title (#28902) (#28912)

Backport #28902 by @JakobDev

Fixes #28846

Co-authored-by: JakobDev <jakobdev@gmx.de>
8 months agoFix sort bug on repository issues list (#28897) (#28901)
Giteabot [Tue, 23 Jan 2024 07:00:52 +0000 (15:00 +0800)]
Fix sort bug on repository issues list (#28897) (#28901)

Backport #28897 by @lunny

Fix #28896

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoFix `DeleteCollaboration` transaction behaviour (#28886) (#28889)
Giteabot [Mon, 22 Jan 2024 08:10:45 +0000 (16:10 +0800)]
Fix `DeleteCollaboration` transaction behaviour (#28886) (#28889)

Backport #28886 by @KN4CK3R

The method can't be called with an outer transaction because if the user
is not a collaborator the outer transaction will be rolled back even if
the inner transaction uses the no-error path.

`has == 0` leads to `return nil` which cancels the transaction. A
standalone call of this method does nothing but if used with an outer
transaction, that will be canceled.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
8 months agoFix schedule not trigger bug because matching full ref name with short ref name ...
Giteabot [Mon, 22 Jan 2024 05:33:14 +0000 (13:33 +0800)]
Fix schedule not trigger bug because matching full ref name with short ref name (#28874) (#28888)

Backport #28874 by @lunny

Fix #28533

Caused by #28691

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoFix uploaded artifacts should be overwritten (#28726) backport v1.21 (#28832)
FuXiaoHei [Mon, 22 Jan 2024 01:49:21 +0000 (09:49 +0800)]
Fix uploaded artifacts should be overwritten (#28726) backport v1.21 (#28832)

Backport https://github.com/go-gitea/gitea/pull/28726 by @fuxiaohei

Fix Uploaded artifacts should be overwritten
https://github.com/go-gitea/gitea/issues/28549

When upload different content to uploaded artifact, it checks that
content size is not match in db record with previous artifact size, then
the new artifact is refused.

Now if it finds uploading content size is not matching db record when
receiving chunks, it updates db records to follow the latest size value.

8 months agoPrevent anonymous container access if `RequireSignInView` is enabled (#28877) (#28882)
Giteabot [Sun, 21 Jan 2024 17:44:38 +0000 (01:44 +0800)]
Prevent anonymous container access if `RequireSignInView` is enabled (#28877) (#28882)

Backport #28877 by @KN4CK3R

Fixes #28875

If `RequireSignInView` is enabled, the ghost user has no access rights.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
8 months agoFix migrate storage bug (#28830) (#28867)
Giteabot [Sun, 21 Jan 2024 16:32:06 +0000 (00:32 +0800)]
Fix migrate storage bug (#28830) (#28867)

Backport #28830 by @lunny

Fix #28728

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoFix incorrect PostgreSQL connection string for Unix sockets (#28865) (#28870)
Giteabot [Sun, 21 Jan 2024 16:06:34 +0000 (00:06 +0800)]
Fix incorrect PostgreSQL connection string for Unix sockets (#28865) (#28870)

Backport #28865 by @sdvcrx

Fix #28864

Co-authored-by: sdvcrx <memory.silentvoyage@gmail.com>
8 months agoAvoid duplicate JS error messages on UI (#28873) (#28881)
Giteabot [Sun, 21 Jan 2024 15:40:26 +0000 (23:40 +0800)]
Avoid duplicate JS error messages on UI (#28873) (#28881)

Backport #28873 by wxiaoguang

Gitea treat JS errors seriously, so sometimes the JS errors caused by
3rdparty code (eg: browser extensions) would also be reported on Gitea
UI: TypeError: WeakMap key undefined (caused by extension DarkReader's
bug) #28861

To avoid fill the user's screen with a lot of error messages, this PR
merges the same error messages into one.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
8 months agoWarn that `DISABLE_QUERY_AUTH_TOKEN` is false only if it's explicitly defined (#28783...
Giteabot [Sun, 21 Jan 2024 15:21:22 +0000 (23:21 +0800)]
Warn that `DISABLE_QUERY_AUTH_TOKEN` is false only if it's explicitly defined (#28783) (#28868)

Backport #28783 by @yardenshoham

So we don't warn on default behavior

- Fixes https://github.com/go-gitea/gitea/issues/28758
- Follows https://github.com/go-gitea/gitea/pull/28390

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: Yarden Shoham <git@yardenshoham.com>
8 months agoFix archive creating LFS hooks and breaking pull requests (#28848) (#28851)
Giteabot [Sun, 21 Jan 2024 14:43:31 +0000 (22:43 +0800)]
Fix archive creating LFS hooks and breaking pull requests (#28848) (#28851)

Backport #28848 by @brechtvl

When LFS hooks are present in gitea-repositories, operations like git
push for creating a pull request fail. These repositories are not meant
to include LFS files or git push them, that is handled separately. And
so they should not have LFS hooks.

Installing git-lfs on some systems (like Debian Linux) will
automatically set up /etc/gitconfig to create LFS hooks in repositories.
For most git commands in Gitea this is not a problem, either because
they run on a temporary clone or the git command does not create LFS
hooks.

But one case where this happens is git archive for creating repository
archives. To fix that, add a GIT_CONFIG_NOSYSTEM=1 to disable using the
system configuration for that command.

According to a comment, GIT_CONFIG_NOSYSTEM is not used for all git
commands because the system configuration can be intentionally set up
for Gitea to use.

Resolves #19810, #21148

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
8 months agoFix reverting a merge commit failing (#28794) (#28825)
Mihir Joshi [Sun, 21 Jan 2024 14:18:37 +0000 (19:48 +0530)]
Fix reverting a merge commit failing (#28794) (#28825)

Backport https://github.com/go-gitea/gitea/pull/28794

Fixes #22236

---
Error occurring currently while trying to revert commit using read-tree
-m approach:
> 2022/12/26 16:04:43 ...rvices/pull/patch.go:240:AttemptThreeWayMerge()
[E] [63a9c61a] Unable to run read-tree -m! Error: exit status 128 -
fatal: this operation must be run in a work tree
>   - fatal: this operation must be run in a work tree

We need to clone a non-bare repository for `git read-tree -m` to work.

https://github.com/go-gitea/gitea/commit/bb371aee6ecf5e570cdf7b5f7f0d6f47a607a325
adds support to create a non-bare cloned temporary upload repository.

After cloning a non-bare temporary upload repository, we [set default
index](https://github.com/go-gitea/gitea/blob/main/services/repository/files/cherry_pick.go#L37)
(`git read-tree HEAD`).
This operation ends up resetting the git index file (see investigation
details below), due to which, we need to call `git update-index
--refresh` afterward.

Here's the diff of the index file before and after we execute
SetDefaultIndex: https://www.diffchecker.com/hyOP3eJy/

Notice the **ctime**, **mtime** are set to 0 after SetDefaultIndex.

You can reproduce the same behavior using these steps:
```bash
$ git clone https://try.gitea.io/me-heer/test.git -s -b main
$ cd test
$ git read-tree HEAD
$ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00
error: Entry '1' not uptodate. Cannot merge.
```

After which, we can fix like this:
```bash
$ git update-index --refresh
$ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00
```

8 months agotests: missing refs/ in bare repositories (#28844) (#28852)
Giteabot [Fri, 19 Jan 2024 07:39:21 +0000 (15:39 +0800)]
tests: missing refs/ in bare repositories (#28844) (#28852)

Backport #28844 by @AdamMajer

Git 2.43.0 will not detect a git repository as valid without refs/
subdirectory present. `git gc` cleans this up and puts it in
packed-refs. We must keep refs/ non-empty.

Co-authored-by: Adam Majer <amajer@suse.de>
8 months agoRemove duplicated checkinit on git module (#28824) (#28831)
Giteabot [Wed, 17 Jan 2024 10:16:33 +0000 (18:16 +0800)]
Remove duplicated checkinit on git module (#28824) (#28831)

Backport #28824 by @lunny

`checkInit` has been invoked in `InitSimple`. So it's unnecessary to
invoke it twice in `InitFull`.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
8 months agoBump `@github/relative-time-element` to 4.3.1 (#28819) (#28826)
Yarden Shoham [Wed, 17 Jan 2024 09:52:06 +0000 (11:52 +0200)]
Bump `@github/relative-time-element` to 4.3.1 (#28819) (#28826)

Backport #28819

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

# Before

![image](https://github.com/go-gitea/gitea/assets/20454870/65d8dc84-680f-4c16-9aa1-b5986102e4e7)

# After

![image](https://github.com/go-gitea/gitea/assets/20454870/7cb288e7-ebde-4e94-a10a-cac28d6bdcfd)

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
8 months agoAdd changelog for 1.21.4 (#28812) v1.21.4
Lunny Xiao [Wed, 17 Jan 2024 02:46:50 +0000 (10:46 +0800)]
Add changelog for 1.21.4 (#28812)

8 months agoRender code block in activity tab (#28816) (#28818)
Giteabot [Wed, 17 Jan 2024 00:35:26 +0000 (08:35 +0800)]
Render code block in activity tab (#28816) (#28818)

Backport #28816 by @JakobDev

This is a little bugfix. Inline code is usually rendered in issue
titles, but it is missing in the activity tab.

Before:
![Screenshot 2024-01-16 at 14-20-51
Test](https://github.com/go-gitea/gitea/assets/15185051/383370f3-0fb2-49de-81cc-014e5cf86727)
After:

![grafik](https://github.com/go-gitea/gitea/assets/15185051/83eaf973-ce9a-44ce-beea-2db49fc8bd73)

Co-authored-by: JakobDev <jakobdev@gmx.de>
9 months agoUse refname:strip-2 instead of refname:short when syncing tags (#28797) (#28811)
Giteabot [Tue, 16 Jan 2024 07:33:33 +0000 (15:33 +0800)]
Use refname:strip-2 instead of refname:short when syncing tags (#28797) (#28811)

Backport #28797 by @lunny

Fix #28694

Generally, `refname:short` should be equal to `refname:lstrip=2` except
`core.warnAmbiguousRefs is used to select the strict abbreviation mode.`

ref:
https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
9 months agoRework markup link rendering (#26745) (#28803)
KN4CK3R [Tue, 16 Jan 2024 02:13:29 +0000 (03:13 +0100)]
Rework markup link rendering (#26745) (#28803)

Backport #26745
Fixes #26548

This PR refactors the rendering of markup links. The old code uses
`strings.Replace` to change some urls while the new code uses more
context to decide which link should be generated.

The added tests should ensure the same output for the old and new
behaviour (besides the bug).

We may need to refactor the rendering a bit more to make it clear how
the different helper methods render the input string. There are lots of
options (resolve links / images / mentions / git hashes / emojis / ...)
but you don't really know what helper uses which options. For example,
we currently support images in the user description which should not be
allowed I think:

<details>
  <summary>Profile</summary>

https://try.gitea.io/KN4CK3R

![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5)

</details>

9 months agoForbid removing the last admin user (#28337) (#28793)
Giteabot [Tue, 16 Jan 2024 01:51:46 +0000 (09:51 +0800)]
Forbid removing the last admin user (#28337) (#28793)

Backport #28337 by @yp05327

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
9 months agoFix links in issue card (#28806) (#28807)
Giteabot [Tue, 16 Jan 2024 01:30:07 +0000 (09:30 +0800)]
Fix links in issue card (#28806) (#28807)

Backport #28806 by @denyskon

Fixes_
https://github.com/go-gitea/gitea/issues/23318#issuecomment-1611086747

Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
9 months agoFix `GetCommitStatuses` (#28787) (#28804)
KN4CK3R [Mon, 15 Jan 2024 18:30:12 +0000 (19:30 +0100)]
Fix `GetCommitStatuses` (#28787) (#28804)

Backport #28787

Replaces #28802

9 months agoUse correct `has error` check for internal responses (#28796) (#28798)
Giteabot [Mon, 15 Jan 2024 12:13:35 +0000 (20:13 +0800)]
Use correct `has error` check for internal responses (#28796) (#28798)

Backport #28796 by @wxiaoguang

`resp != nil` doesn't mean the request really succeeded. Add a comment
for requestJSONResp to clarify the behavior.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
9 months agoFix nil pointer panic when exec some gitea cli command (#28791) (#28795)
Giteabot [Mon, 15 Jan 2024 08:05:30 +0000 (16:05 +0800)]
Fix nil pointer panic when exec some gitea cli command (#28791) (#28795)

Backport #28791 by @yp05327

panic:

![image](https://github.com/go-gitea/gitea/assets/18380374/7fcde2ad-1d42-4b60-b120-3b60a8926e8e)

After:

![image](https://github.com/go-gitea/gitea/assets/18380374/49d9f0ca-e590-4a35-8ca2-1317d1b7c939)

Co-authored-by: yp05327 <576951401@qq.com>
9 months agoFix when private user following user, private user will not be counted in his own...
Giteabot [Mon, 15 Jan 2024 07:07:10 +0000 (15:07 +0800)]
Fix when private user following user, private user will not be counted in his own view (#28037) (#28792)

Backport #28037 by @yp05327

Doer: asdasasdasasdasasdasasdasasdasasdasasdas (private user)
Followed: TestUser (public user)

Before:
(From doer's view)

![image](https://github.com/go-gitea/gitea/assets/18380374/9ba16b3b-068c-43c5-a3dd-e3343b5b32f2)
(From followed user's view, can see doer)

![image](https://github.com/go-gitea/gitea/assets/18380374/dfd1b564-d689-4393-b3d3-1e6bf52c94ba)

After:
(From doer's view)

![image](https://github.com/go-gitea/gitea/assets/18380374/1c85c1d1-c9f7-40c8-948c-145f7cae9a04)

Co-authored-by: yp05327 <576951401@qq.com>