Commit Graph

5010 Commits

Author SHA1 Message Date
Gregorius Bima Kharisma Wicaksana
83527d3f8a
Support closing keywords with URL references (#36221)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
## Summary

This PR adds support for closing keywords (`closes`, `fixes`, `reopens`,
etc.) with full URL references in markdown links.

**Before:**
- `closes #123`  works
- `closes org/repo#123`  works  
- `Closes [this issue](https://gitea.io/user/repo/issues/123)`  didn't
work
- `Fixes [#456](https://gitea.io/org/project/issues/456)`  didn't work

**After:**
All of the above now work correctly.

## Problem

When users reference issues using full URLs in markdown links (e.g.,
`Closes [this issue](https://gitea.io/user/repo/issues/123)`), the
closing keywords were not detected. This was because the URL processing
code explicitly stated:

```go
// Note: closing/reopening keywords not supported with URLs
```

Both methods of writing the reference render the same in the UI, so
users expected the closing keywords to behave the same.

## Solution

The fix works by:
1. Passing the original (unstripped) content to
`findAllIssueReferencesBytes`
2. When processing URL links from markdown, finding the URL position in
the original content
3. For markdown links `[text](url)`, finding the opening bracket `[`
position
4. Using that position to detect closing keywords before the link

## Testing

Added test cases for:
- `Closes [this issue](url)` - single URL with closing keyword
- `This fixes [#456](url)` - keyword in middle of text
- `Reopens [PR](url)` - reopen keyword with pull request URL
- Multiple URLs where only one has a closing keyword

All existing tests continue to pass.

Fixes #27549
2025-12-27 09:05:24 -08:00
Lunny Xiao
00cc84e37c
remove nolint (#36252) 2025-12-26 22:55:30 -08:00
Lunny Xiao
ff3d68b98a
Fix panic when get editor config file (#36241)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Fix #36239
2025-12-25 19:26:23 -08:00
Lunny Xiao
324dcf6f64
Use flatten translation keys (#36225)
Crowdin does not remove empty lines in nested JSON translation files.
Therefore, we use flattened translation keys instead. We have also
updated the key-loading logic to ensure that empty values are not
applied during translation.

---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2025-12-25 12:51:33 -08:00
silverwind
42d294941c
Replace CSRF cookie with CrossOriginProtection (#36183)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Removes the CSRF cookie in favor of
[`CrossOriginProtection`](https://pkg.go.dev/net/http#CrossOriginProtection)
which relies purely on HTTP headers.

Fixes: https://github.com/go-gitea/gitea/issues/11188
Fixes: https://github.com/go-gitea/gitea/issues/30333
Helps: https://github.com/go-gitea/gitea/issues/35107

TODOs:

- [x] Fix tests
- [ ] Ideally add tests to validates the protection

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-25 12:33:34 +02:00
Lunny Xiao
ffea9a27c3
Convert locale files from ini to json format (#35489)
Migrate from the current INI format to JSON for translations. JSON is
widely supported, including by platforms such as Crowdin and Weblate.
2025-12-19 09:50:48 -08:00
silverwind
1e22bd712f
Bump golangci-lint to 2.7.2, enable modernize stringsbuilder (#36180)
Fixes were done automatically by `make lint-go-fix`. These modernize
fixes are very readable.

Co-authored-by: Giteabot <teabot@gitea.io>
2025-12-17 20:50:53 +00:00
Lunny Xiao
ebf9b4dc6b
Use a migration test instead of a wrong test which populated the meta test repositories and fix a migration bug (#36160)
The test `TestGiteaUploadUpdateGitForPullRequest` modified the shared
meta test repositories directly, so this PR removes that test and
replaces it with an integration test that migrates a real repository
from gitea.com into a local test instance.

This PR also fixes a bug where pull-request migrations were not
correctly syncing head branches to the database.
2025-12-17 12:00:07 -08:00
silverwind
852bf5e2a5
Add git.DIFF_RENAME_SIMILARITY_THRESHOLD option (#36164)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Make the threshold value passed to `git diff --find-renames` configurable
2025-12-17 10:02:32 +00:00
Lunny Xiao
4c67aac23b
Move blame to gitrepo (#36161) 2025-12-16 16:14:14 -08:00
silverwind
84b74d7c3e
Enable bodyclose linter (#36168)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Enabe
[`bodyclose`](https://golangci-lint.run/docs/linters/configuration/#bodyclose).
The only issue in non-test code (`services/migrations/dump.go`) was a
false-positive and I think there are a number of undetected cases, but I
guess it's still better than not having it.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2025-12-16 14:08:43 +01:00
Lunny Xiao
da087270ff
Some small refactors (#36163) 2025-12-15 11:55:44 -08:00
Lunny Xiao
26602fd207
Remove undocumented support of signing key in the repository git configuration file (#36143)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Per-repository signing keys have never been officially supported, as
they would require users to modify the repository’s config file.

At this point, it is clear that only global signing keys (GPG or SSH)
should be allowed. If we want to introduce per-repository signing keys
in the future, it will require a complete design proposal.

The endpoint will not be removed for repository special signing key, but
it will reference the global signing key.

---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-12-14 17:34:45 +00:00
wxiaoguang
7190519fb3
Fix code highlighting on blame page (#36157)
1. Full file highlighting (fix the legacy todo "we should instead
highlight the whole file at once")
    * Fix #24383
2. Correctly covert file content encoding
3. Remove dead code, split large for-loop into small functions/blocks to
make code maintainable
2025-12-14 12:40:55 +02:00
Lunny Xiao
29057ea55f
Fix bug when viewing the commit diff page with non-ANSI files (#36149)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
Fix #35504

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-13 21:54:03 +08:00
wxiaoguang
1e72b15639
Fix various bugs (#36139)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-container (push) Waiting to run
* Fix #35768
* Fix #36064
* Fix #36051
* Fix cherry-pick panic
2025-12-12 18:56:05 +00:00
Lunny Xiao
d2a372fc59
Move some functions to gitrepo package to reduce RepoPath reference directly (#36126) 2025-12-12 01:15:40 +01:00
wxiaoguang
f25409fab8
Make Golang correctly delete temp files during uploading (#36128)
Fix #36127
2025-12-11 19:59:42 +01:00
Lunny Xiao
a440116a16
Support updating branch via API (#35951)
Resolve #35368
2025-12-10 19:23:26 +00:00
Lunny Xiao
24b81ac8b9
Use gitrepo's clone and push when possible (#36093)
1 Move `IsRepositoryModelOrDirExist` and `CheckCreateRepository` to
service layer
2 Use `gitrepo.Pushxxx` instead of `git.Push` when possible
3 use `gitrepo.Clonexxx` instead of `gitrepo.Clone` when possible
2025-12-10 09:41:01 -08:00
wxiaoguang
1c69fdccdd
Improve math rendering (#36124)
Fix #36108
Fix #36107
2025-12-10 15:49:24 +00:00
Ger Schinkel
d83a071db9
Changed a small typo in an error message and code comments. (#36117) 2025-12-09 10:14:05 -05:00
Lunny Xiao
64960a18f9
Move commit related functions to gitrepo package (#35600) 2025-12-05 00:20:23 +00:00
a1012112796
ee365f5100
fix some file icon ui (#36078)
fix #36071

looks that's because if an svg in hiden env, it's color added by
`fill="url(#a)"` will become not usefull. by ai helping, I think moving
it out of page by position is a good solution. fell free creat a new
pull request if you have a better soluton. Thanks.
<img width="2198" height="1120" alt="image"
src="https://github.com/user-attachments/assets/bbf7c171-0b7f-412a-a1bc-aea3f1629636"
/>

---------

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-04 19:47:23 +01:00
silverwind
b49dd8e32f
update golangci-lint to v2.7.0 (#36079)
- Update and autofix most issues
- Corrected variable names to `cutOk`
- Impossible condition in `services/migrations/onedev_test.go` removed
- `modules/setting/config_env.go:128:3` looks like a false-positive,
added nolint
2025-12-04 09:06:44 +00:00
wxiaoguang
000c06d41b
Fix oauth2 session gob register (#36017)
`gob.Register` must be called before Sessioner

Fix #36016
2025-11-26 23:25:34 +08:00
wxiaoguang
e1372e5bc1
Make composer registry support tar.gz and tar.bz2 and fix bugs (#35958)
Fix #35957
2025-11-18 23:15:50 +00:00
Daniel Mach
d6dc531d4b
Add GITEA_PR_INDEX env variable to githooks (#35938)
`GITEA_PR_ID` is already part of the env variables available in the
githooks, but it contains a database ID instead of commonly used index
that is part of `owner/repo!index`
2025-11-14 04:21:05 +00:00
wxiaoguang
372d24b84b
Limit reading bytes instead of ReadAll (#35928) 2025-11-12 19:44:49 +08:00
wxiaoguang
e31f224ad2
Make OAuth2 issuer configurable (#35915)
The new (correct) behavior breaks the old (incorrect) logins.

Add a config option to support legacy "issuer".

Fix #35830
2025-11-10 23:45:01 +08:00
lifegpc
1c8c56503f
Allow to display embed images/pdfs when SERVE_DIRECT was enabled on MinIO storage (#35882)
Releated issue: https://github.com/go-gitea/gitea/issues/30487

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-11-09 21:31:25 -08:00
wxiaoguang
525265c1a8
Refactor ls-tree and git path related problems (#35858)
Fix #35852, the root problem is that the "name" field is heavily abused
(since #6816, and no way to get a clear fix)

There are still a lot of legacy problems in old code.

Co-authored-by: Giteabot <teabot@gitea.io>
2025-11-05 17:48:38 +00:00
wxiaoguang
a0f492d9f4
Make ACME email optional (#35849)
Fix a regression from #33668

Fix #35847
2025-11-04 18:17:50 +00:00
silverwind
8b290b87e9
Improve and fix markup code preview rendering (#35777)
1. Add the color on the link to the referenced file, which is the more
likely thing the user wants to click
2. Use monospace font on the SHA
3. Tweak text colors
4. Change SHA link to go to the commit instead of the repo root with
commit filter set
5. Added the repo name to the file link text
6. Fix broken line numbering rendering
2025-10-30 05:15:42 +00:00
bytedream
39c08ce4c1
Update tab title when navigating file tree (#35757)
Fix #35749.

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2025-10-29 13:38:09 +00:00
wxiaoguang
6b5563c54a
Support selecting theme on the footer (#35741)
Fixes: https://github.com/go-gitea/gitea/pull/27576
2025-10-28 18:25:00 +08:00
Lunny Xiao
304d836a61
Fix shutdown waitgroup panic (#35676)
This PR fixes a panic issue in the WaitGroup that occurs when Gitea is
shut down using Ctrl+C.
It ensures that all active connection pointers in the server are
properly tracked and forcibly closed when the hammer shutdown is
invoked.
The process remains graceful — the normal shutdown sequence runs before
the hammer is triggered, and existing connections are given a timeout
period to complete gracefully.

This PR also fixes `no logger writer` problem. Now the log close will
only be invoked when the command exit.

- Fixes #35468
- Fixes #35551
- Fixes #35559
- Replace #35578

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-25 00:02:58 -07:00
wxiaoguang
cb72c901b3
Intorduce "config edit-ini" sub command to help maintaining INI config file (#35735)
Ref: #32669. Helps addressing
https://gitea.com/gitea/helm-chart/issues/356.
2025-10-25 10:54:55 +08:00
wxiaoguang
9a73a1fb83
Make "update file" API can create a new file when SHA is not set (#35738)
Fix #19008, use GitHub's behavior (empty SHA to create a new file)
2025-10-24 12:46:54 +08:00
silverwind
cab35ff17a
Update dependencies (#35733)
- Update all JS, Python and Makefile dependencies
- Fixed two new go lint issues
- Tested the affected JS dependencies.
2025-10-23 08:35:48 +00:00
wxiaoguang
522c466e24
Make external iframe render work (#35730)
Fix #35729, #17635, #21098
2025-10-23 08:01:38 +00:00
wxiaoguang
195fc715ff
Fix external render (#35727)
Fix #35725

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-22 23:41:38 +00:00
Kemal Zebari
a9f2ea720b
Honor delete branch on merge repo setting when using merge API (#35488)
Fix #35463.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-22 05:06:56 +00:00
a1012112796
a4e23b81d3
fix attachment file size limit in server backend (#35519)
fix #35512

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-10-21 15:07:11 +00:00
wxiaoguang
b2ee5be52e
Refactor legacy code (#35708)
And by the way, remove the legacy TODO, split large functions into small
ones, and add more tests
2025-10-20 11:43:08 -07:00
wxiaoguang
66ee8f3553
Avoid emoji mismatch and allow to only enable chosen emojis (#35692)
Fix #23635
2025-10-19 13:06:45 -07:00
wxiaoguang
2d36a0c9ff
Fix various bugs (#35684)
1. Fix incorrect column in `applySubscribedCondition`, add a test
2. Fix debian version parsing, add more tests fix #35695
3. Fix log level for HTTP errors, fix #35651
4. Fix abused "panic" handler in API `Migrate`
5. Fix the redirection from PR to issue, add a test
6. Fix Actions variable & secret name validation, add more tests
    * envNameCIRegexMatch is unnecessary, removed
    * validating in "delete" function doesn't make sense, removed
7. Fix incorrect link in release email

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-10-19 00:37:50 +08:00
Lunny Xiao
a7eceb57a9
Use gitrepo.Repository instead of wikipath (#35398)
Now the wikipath will not be referenced directly.
2025-10-17 20:00:44 -07:00
wxiaoguang
c55a017225
Fix missing Close when error occurs and abused connection pool (#35658)
Fix #35649

* Use upstream `git-lfs-transfer`
* The Close should be called when error occurs (bug fix)
* The connection pool should be shared (bug fix)
* Add more tests to cover "LFS over SSH download"
2025-10-15 09:47:12 +00:00
Lunny Xiao
1bdb0b71b1
Upgrade to go 1.25.3 (#35656) 2025-10-15 10:09:32 +02:00