1876 Commits

Author SHA1 Message Date
Joakim Olsson
1ee7f8e966 fix: prevent panic when GitLab release has more links than sources (#36295)
The code incorrectly assumed rel.Assets.Links and rel.Assets.Sources
arrays have equal length. This causes index out of bounds panic when
migrating GitLab releases with more links than sources, which is common
with GoReleaser-generated releases.

Fixes #36292

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-01-05 21:48:12 +08:00
Lunny Xiao
426bb491c0 Move assign project when creating pull request to the same database transaction (#36244)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
2026-01-04 16:45:36 +00:00
wxiaoguang
b79dbfa990 Fix link/origin referrer and login redirect (#36279)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Fix #35998

1. Fix `<a rel>` :
    * "_blank" already means "noopener"
* "noreferrer" is already provided by page's `<meta name="referrer">`
2. Fix "redirect_to" mechisam
* Use "referer" header to determine the redirect link for a successful
login
3. Simplify code and merge duplicate logic
2026-01-03 11:43:04 +08:00
Lunny Xiao
8373f7deb3 improve the compare page (#36261)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
- The compare page head title should be `compare` but not `new pull
request`.
- Use `UnstableGuessRefByShortName` instead of duplicated functions
calls.
- Direct-compare, tags, commits compare will not display `New Pull
Request` button any more.

The new screenshot
<img width="1459" height="391" alt="image"
src="https://github.com/user-attachments/assets/64e9b070-9c0b-41d1-b4b8-233b96270e1b"
/>

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-01-01 10:32:19 -08:00
luo jiyin
98981eb749 mailer: pass request context to generateAdditionalHeadersForIssue (#36274)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Fixes #36273

Use the caller-provided context when building X-Gitea-Issue-Link,
instead of `context.TODO()`.
2026-01-01 04:28:25 +00:00
Max P.
91d871611e feat(debian): use explicit, stronger defaults for newly generated repo signing keys (#36236)
Make Debian repository signing key generation use explicit stronger defaults
and embed the creation time in the OpenPGP comment for newly created keys.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-01-01 02:36:14 +00:00
Lunny Xiao
1771569300 Some refactor for repo path (#36251)
Some checks failed
cron-translations / crowdin-pull (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
- Use `gitrepo.IsRepositoryExist` instead of `util.IsExit` or
`util.IsDir`
- Use `gitrepo.OpenRepository` instead of `git.OpenRepository`
- Use `gitrepo.DeleteRepository` instead of `util.RemoveAll`
- Use `gitrepo.RenameRepository` instead of `util.Rename`
2025-12-29 18:49:54 +00:00
Lunny Xiao
c7b3cdf7b1 Use gitrepo's push function (#36245)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
extract from #36186
2025-12-28 13:24:28 +02:00
Ivan Tkatchev
19e1997ee2 Add an option to automatically verify SSH keys from LDAP (#35927)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
This pull request adds an option to automatically verify SSH keys from
LDAP authentication sources.

This allows a correct authentication and verification workflow for
LDAP-enabled organizations; under normal circumstances SSH keys in LDAP
are not managed by users manually.
2025-12-27 12:33:08 +00:00
sollyu
64fcf847ce Use the requested host for LFS links (#36242)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Use the dynamically parsed host in the request for LFS links, but not
use the hard-coded AppURL.

Make LFS server support multi-domain or run Gitea behind a reverse-proxy
with different ROOT_URL.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-26 04:48:20 +00:00
Lunny Xiao
776e406363 Refactor compare router param parse (#36105)
---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-25 17:51:30 -08:00
silverwind
42d294941c Replace CSRF cookie with CrossOriginProtection (#36183)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
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
3e566172f5 Use gitRepo as parameter instead of repopath when invoking sign functions (#36162)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
Co-authored-by: Giteabot <teabot@gitea.io>
2025-12-17 21:55:08 +00: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 failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Make the threshold value passed to `git diff --find-renames` configurable
2025-12-17 10:02:32 +00:00
wxiaoguang
eaa47c3e09 Fix OrgAssignment opts (#36174)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
Fix #36084
2025-12-17 17:19:22 +08:00
Dawid Góra
0e916c67cc Automatic generation of release notes (#35977)
Similar to GitHub, release notes can now be generated automatically.
The generator is server-side and gathers the merged PRs and contributors
and returns the corresponding Markdown text.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-17 02:01:19 +00:00
Sebastian Ertz
14911d4293 Update chroma to v2.21.0 (#36171)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
https://github.com/alecthomas/chroma/releases/tag/v2.21.0
2025-12-17 01:07:44 +00:00
silverwind
84b74d7c3e Enable bodyclose linter (#36168)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
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
TheFox0x7
3bb0770160 fix nilnil in onedev downloader (#36154)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
onedev migration never used the migration transport, it now uses it the
same way gogs one does

---

cuts 3 nilnils for https://github.com/go-gitea/gitea/issues/36152
2025-12-16 02:16:58 +00: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 failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
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
1f5237e0d7 Check user visibility when redirecting to a renamed user (#36148)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
Fix #34169
2025-12-14 03:14:18 +01:00
Lunny Xiao
29057ea55f Fix bug when viewing the commit diff page with non-ANSI files (#36149)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
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 failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
* 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)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Fix #36127
2025-12-11 19:59:42 +01:00
Lunny Xiao
a440116a16 Support updating branch via API (#35951)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
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
Ger Schinkel
d83a071db9 Changed a small typo in an error message and code comments. (#36117)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
2025-12-09 10:14:05 -05:00
Lunny Xiao
69700f9cdd Fix possible bug when migrating issues/pull requests (#33487)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
When migrating issues or pull requests from a big repository, some
issue/pull request maybe deleted when migrating. So that there will be
duplicated issues/pull requests because we are get information with
pagination. This PR introduced a map to record all migrated issue pull
request index when migrating to avoid the failure because of duplicated
records.
2025-12-07 23:09:10 -08: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)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
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)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
- 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
Lunny Xiao
ee6e371e44 Use Golang net/smtp instead of gomail's smtp to send email (#36055)
Replace #36032
Fix #36030

This PR use `net/smtp` instead of gomail's smtp. Now
github.com/wneessen/go-mail will be used only for generating email
message body.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
2025-12-04 08:35:53 +00:00
Lunny Xiao
e30a130b9a Fix edit user email bug in API (#36068)
Follow #36058 for API edit user bug when editing email.

- The Admin Edit User API includes a breaking change. Previously, when
updating a user with an email from an unallowed domain, the request
would succeed but return a warning in the response headers. Now, the
request will fail and return an error in the response body instead.
- Removed `AdminAddOrSetPrimaryEmailAddress` because it will not be used
any where.

Fix https://github.com/go-gitea/gitea/pull/36058#issuecomment-3600005186

---------

Co-authored-by: Giteabot <teabot@gitea.io>
2025-12-04 09:05:13 +01:00
Lunny Xiao
5340db4dbe Fix bug when updating user email (#36058)
Fix #20390 

We should use `ReplacePrimaryEmailAddress` instead of
`AdminAddOrSetPrimaryEmailAddress` when modify user's email from admin
panel. And also we need a database transaction to keep deletion and
insertion succeed at the same time.
2025-12-01 23:50:10 +00:00
Bryan Mutai
7d6861ac54 Add "Go to file", "Delete Directory" to repo file list page (#35911)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
/claim #35898
Resolves #35898 

### Summary of key changes:

1. Add file name search/Go to file functionality to repo button row.
2. Add backend functionality to delete directory
3. Add context menu for directories with functionality to copy path & delete a directory
4. Move Add/Upload file dropdown to right for parity with Github UI
5. Add tree view to the edit/upload UI

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-11-30 11:58:15 +08:00
Zettat123
f4e38e6367 Fix Actions pull_request.paths being triggered incorrectly by rebase (#36045)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
Partially fix #34710 

The bug described in #34710 can be divided into two parts: `push.paths`
and `pull_request.paths`. This PR fixes the issue related to
`pull_request.paths`. The root cause is that the check for whether the
workflow can be triggered happens **before** updating the PR’s merge
base. This causes the file-change detection to use the old merge base.
Therefore, we need to update the merge base first and then check whether
the workflow can be triggered.
2025-11-28 19:33:52 +00:00
hamkido
a36951aef6 Fix error handling in mailer and wiki services (#36041)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
- Updated error message in `incoming.go` to remove unnecessary wrapping
of the error.
- Corrected typo in error message in `wiki.go` for clarity.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
2025-11-28 00:36:27 +00:00
bytedream
ede7f1a069 Fix incorrect viewed files counter if file has changed (#36009)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
File changes since last review didn't decrease the viewed files counter

---
<img width="440" height="178" alt="image"
src="https://github.com/user-attachments/assets/da34fcf4-452f-4f71-8da2-97edbfc31fdd"
/>

Also reported here ->
https://github.com/go-gitea/gitea/issues/35803#issuecomment-3567850285

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2025-11-27 14:02:03 +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
Andrew Melnick
688430e3ce Allow admins to rename non-local users (#35970)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
Presently, attempting to rename a non-local (e.g. Oauth2 or LDAP) user
results in an error, even if the requester is an administrator. As far
as I can tell, this is a security feature, not architectural in nature,
as automatic account linking could be used to take control of another
user's account. This is not a concern for an administrator, who we
should trust to know what they are doing.

This patch allows admins, and only admins, to rename non-local users.

Fixes https://github.com/go-gitea/gitea/issues/18308 (sort of)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-11-23 20:59:55 +00:00
Zettat123
ed977d9702 Use GitHub-style commit message for squash merge (#35987)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
2025-11-22 09:20:45 -08:00
Lunny Xiao
62d750eadb Fix various permission & login related bugs (#36002)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
Permission & protection check:

- Fix Delete Release permission check
- Fix Update Pull Request with rebase branch protection check
- Fix Issue Dependency permission check
- Fix Delete Comment History ID check

Information leaking:

- Show unified message for non-existing user and invalid password
    - Fix #35984
- Don't expose release draft to non-writer users.
- Make API returns signature's email address instead of the user
profile's.

Auth & Login:

- Avoid GCM OAuth2 attempt when OAuth2 is disabled
    - Fix #35510

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-11-22 07:16:08 +00:00
Lunny Xiao
a60a8c6966 Allow empty commit when merging pull request with squash style (#35989)
Before this PR, when merging an empty PR with squash style will result
in 500.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-11-22 06:02:25 +00:00
wxiaoguang
0fb3be7f0e Fix diff blob excerpt expansion (#35922)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled
And add comments and tests
2025-11-14 04:50:48 +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