Commit Graph

1336 Commits

Author SHA1 Message Date
silverwind
14d2bdc19a refactor: replace cropperjs with @github/image-crop-element (#40530)
Replace cropperjs, which was stuck on v1 because v2 was too complex to
migrate to, with `@github/image-crop-element`, the cropper GitHub uses
(2.3 KB vs 14.5 KB gzipped). A full selection of a square image uploads
the original file so animated avatars keep working, any other selection
uploads the selected square as PNG.

Custom element events are now typed via `HTMLElementEventMap`, removing
event casts.

<img width="208" height="208" alt="Avatar crop panel with the Gitea
logo"
src="https://github.com/user-attachments/assets/dbdc2744-592a-45ea-91d2-356c34a0d52b">

Ref: https://github.com/go-gitea/gitea/pull/33827

Assisted-by: Claude Code:claude-opus-5-5
2026-11-26 13:40:23 +00:00
Myers Carpenter
eddd00278b fix(api): exclude code comments from the timeline query, not after paging (#40511)
The issue timeline API paged the comment query and then dropped code
comments from the page, so pages could come back short or empty while
later pages still held events, and clients that stop at such a page
missed them. Code comments are now excluded in the query itself.

Comments the doer cannot read are still filtered after paging, and
`X-Total-Count` still reflects the page length. Both are left for a
follow-up. Independent of https://github.com/go-gitea/gitea/pull/40496
and https://github.com/go-gitea/gitea/pull/40497.

Refs: https://github.com/go-gitea/gitea/issues/40495

Assisted-by: Claude:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-26 11:06:46 +00:00
bircni
933ab82a16 feat: add merge queue (#40431)
Adds a merge queue for protected branches, modeled on GitHub's. Merging
into a branch that requires it queues the pull request, tests it with
the ones ahead of it in `merge_group` runs and fast-forwards the base
once the required checks pass. Failing or conflicting pull requests are
removed.

Rules configure merge method, group sizes, grouping and timeouts. Each
queue has a page at `/{owner}/{repo}/queue/{branch}`. The API can queue,
jump, look up and remove a pull request and list or clear a queue, and
webhooks and Actions get the `merge_group` event and
`enqueued`/`dequeued` actions. The merge box's command line hint now
sits beside the merge buttons like on GitHub, also outside of merge
queues.

One notable difference from GitHub is that Gitea allows merge queue to
be enabled in any repo, as opposed to GitHub which only allows it in
organization repos.

| View | Screenshot |
| --- | --- |
| Merge box, ready | <img width="440" alt="Merge box, ready"
src="https://github.com/user-attachments/assets/7d2ac984-90c4-4744-8ac8-5daf37cd96e9"
/> |
| Merge box, queued | <img width="440" alt="Merge box, queued"
src="https://github.com/user-attachments/assets/33b85cab-dfd6-405f-8ffd-283cd920e59f"
/> |
| Pull request header, queued | <img width="600" alt="Pull request
header, queued"
src="https://github.com/user-attachments/assets/d61c635b-8552-4b47-a900-e493912e8c16"
/> |
| Timeline, removal after failed checks | <img width="440"
alt="Timeline, removal after failed checks"
src="https://github.com/user-attachments/assets/bee95e79-4c76-4592-ad35-82109d9da4ed"
/> |
| Queue page | <img width="600" alt="Queue page"
src="https://github.com/user-attachments/assets/847a595a-1e13-4099-aa37-7f44018dc188"
/> |
| Pull request list, queued | <img width="600" alt="Pull request list,
queued"
src="https://github.com/user-attachments/assets/a382a143-a67f-4298-aa11-594e281d54db"
/> |
| Merge queue settings | <img width="600" alt="Merge queue settings"
src="https://github.com/user-attachments/assets/cdaf4aa5-350e-4570-a095-c91c41d03cde"
/> |

Fixes: https://github.com/go-gitea/gitea/issues/36392
Docs: https://gitea.com/gitea/docs/pulls/655

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
2026-11-26 10:50:01 +00:00
Lunny Xiao
d821a986ef perf(auth): store tokens as SHA-256 and throttle last-used writes (#39933)
Store PAT, Actions task and runner tokens as SHA-256 instead of PBKDF2,
which 160-bit random tokens don't need, and drop the token caches and
`SUCCESSFUL_TOKENS_CACHE_SIZE` that PBKDF2 required. Legacy rows are
rehashed on first use. Older releases can't verify new or rehashed
tokens. A PAT use now writes only its last-used timestamp, at most once
a minute.

Benchmarks on M2 Max, SQLite, median of 5:

| Benchmark | 1 token | 128 tokens |
| :--- | ---: | ---: |
| PAT lookup | 29.4 → 30.7 µs | 2.24 ms → 29.7 µs |
| PAT lookup with last-used | 107 → 29.6 µs | 2.44 ms → 30.1 µs |
| Task lookup | 63.2 → 48.4 µs | 2.25 ms → 49.4 µs |
| Runner verify, no DB | 122 → 160 ns | 141 → 162 ns |

Docs: https://gitea.com/gitea/docs/pulls/607

Assisted-by: Codet
Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-25 15:36:10 +00:00
Lunny Xiao
02b5bbacab fix(release): order the release list by publication time (#39714)
Releases are listed by `created_unix`, which is the date of the tagged
commit since #36761. A patch release tagged on an older branch commit
(e.g. 1.24.x after 1.25.0) therefore sorts out of publication order, so
the newest release is not always at the top.

List by publication time instead, falling back to the commit date for
drafts. The latest-release badge is unchanged, so an old commit still
cannot take it over.

---
Assisted-by: Codet:claude

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-25 15:28:01 +00:00
Christmas
a46dea6651 fix(mirror): keep repository update times out of the future (#40481)
A pull mirror copied its newest branch tip's committer date into the
repository's "Last updated" field. Commit dates are set by whoever made
the commit, so a single tip dated 2098 kept an idle mirror at the top of
Explore for decades.

Like GitHub, GitLab and Gitea's own push handling, a sync now sets the
update time to the sync time when any ref changed and leaves it
untouched otherwise.

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

Assisted-by: Codex:GPT-6
Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-25 10:39:43 +00:00
silverwind
812406423b fix(actions): run workflows on the event's commit (#40112)
Queued push, create and pull request synchronize events resolved their
branch only when handled, so if it had moved on, the pushed commit got
no run and the newer one got two.

Runs now use the event's commit, and a delayed default branch push no
longer replaces newer schedules.

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2026-11-25 03:55:01 +00:00
silverwind
a4d38a5d64 enhance(api): add admin actions variables API (#40522)
Adds `/api/v1/admin/actions/variables` so instance-level actions
variables can be managed outside the admin UI. All variable scopes now
share one handler implementation and one test.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 03:27:49 +00:00
silverwind
b1a6cdadc8 enhance: deprecate minio storage naming, switch to rustfs on ci (#37545)
Use provider-neutral S3 naming for object storage and switch CI to
RustFS.

1. Rename `STORAGE_TYPE = minio` to `s3`, `[storage.minio]` to
`[storage.s3]`, and `MINIO_*` keys to `S3_*`. Legacy configs resolve as
before and log deprecation warnings. Explicit `S3_*` keys take
precedence in the same section.
2. Rename `migrate-storage` options to `--storage=s3` and `--s3-*`,
retaining deprecated `minio` aliases.
3. Replace MinIO in CI with RustFS `1.0.6` and rename
`TEST_MINIO_ENDPOINT` to `TEST_S3_ENDPOINT`.

Docs: https://gitea.com/gitea/docs/pulls/659

Assisted-by: Claude Code:claude-opus-5-5

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-11-24 06:13:13 +00:00
Zhaowei Gu
890effbc91 fix: drain in-flight requests on SIGTERM and close idle connections promptly (#40472)
`gitea web` derived the graceful manager's context from the CLI context,
which is canceled on the first SIGTERM, so in-flight requests were
force-closed and the terminate stage never ran.

- Detach the manager's context from that cancellation. With
`SKIP_MINWINSVC=1` on Windows, Ctrl+C now takes two.
- Close idle HTTP/2 connections at shutdown, which otherwise held every
drain until the hammer.

| SIGTERM with | main | this PR |
|---|---|---|
| no connections | 0.01s, no terminate stage | 1.03s |
| 64 MiB download in flight | cut after 10 MB | completes |
| idle HTTP/2 connection | 0.01s | 1.01s |

Regressed in: https://github.com/go-gitea/gitea/pull/35348
Carries forward https://github.com/go-gitea/gitea/pull/39533 by
@mandel-macaque.

Assisted-by: Hermes Agent:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2026-11-22 10:05:40 +00:00
silverwind
e1d2e94ab0 enhance(actions)!: run pull_request_target workflows from the default branch (#40440)
Like GitHub since December 2025, `pull_request_target` workflows now run
from the default branch whatever the pull request targets, so an
outdated workflow on a release branch can't run with secrets.

`github.ref`, `github.sha` and local reusable workflows follow it, while
branch filters still match the base. Runs now record that ref, so runs
from older versions keep the base on rerun.

Breaking: pull requests targeting a non-default branch now run the
default branch's `pull_request_target` workflows, so workflows that only
exist on that branch stop running and `actions/checkout` without `ref`
checks out the default branch.

Ref:
https://github.blog/changelog/2025-11-07-actions-pull_request_target-and-environment-branch-protections-changes/

Assisted-by: Claude Code:claude-opus-5-5
2026-11-21 18:52:39 +00:00
李浩然
e03fcadc69 enhance(release): show mentioned contributors (#39768)
Show the users @mentioned in release notes as a row of avatars in a
Contributors section below the notes, like GitHub does on its release
pages. Mentions in the notes stay plain links, as on GitHub.

Only active users the viewer can see are listed, in order of first
mention.

| Before | After |
| --- | --- |
| <img width="260" height="77" alt="before"
src="https://github.com/user-attachments/assets/83c015f7-92eb-48da-b09c-42371497d61e"
/> | <img width="260" height="150" alt="after"
src="https://github.com/user-attachments/assets/1467bc1e-59df-42d5-8989-165a502bdb0e"
/> |

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

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: 李浩然 <lihaoran@gzweiti.com>
Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-21 18:48:44 +00:00
silverwind
c64dba88bd fix(actions): find runs awaiting approval behind stale commit statuses (#40476)
The "Approve runs" button was missing on
https://gitea.com/gitea/runner/pulls/1246. The merge box only looked at
the latest commit status per context, so an older run's later update,
like its cancellation, hid a newer run still awaiting approval. It now
collects runs from all statuses of the head commit.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-21 14:40:12 +00:00
silverwind
535a05345b enhance(markup): highlight mentions of the current user (#40474)
Render user mentions like GitHub, semibold in the surrounding text
color, and highlight mentions of the signed-in user in yellow so they
stand out in long threads.

The renderer adds `user-mention` and `current-user` classes, the styling
is pure CSS. CODEOWNERS and OAuth creator links use the same class, team
mentions are unchanged.

| Before | After |
| --- | --- |
| <img width="291" height="29" alt="before"
src="https://github.com/user-attachments/assets/6c451e7a-dfce-4e95-a386-f9aa9d28c721"
/> | <img width="291" height="29" alt="after"
src="https://github.com/user-attachments/assets/6b137c71-4692-46f2-adf8-d77ee87f3077"
/> |

Assisted-by: Claude Code:claude-opus-5-5
2026-11-21 14:39:11 +00:00
silverwind
c9273a5a59 test: wait for indexer startup before loading fixtures (#40467)
Integration tests load fixtures after the app starts, while the indexers
still initialize and populate in the background. A slow start indexed
every fixture repo or dropped early index updates, making search tests
flaky.

The indexer startup goroutines now join a WaitGroup that only the test
harness waits on. This replaces the issue indexer's `syncReindex` flag.
Also fixes a flaky `SyncDirs` test that relied on directory listing
order.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-21 02:43:03 +00:00
Shudhanshu Singh
47f627870d enhance(webhooks): show live delivery status in history (#40389)
A webhook delivery looked failed while its HTTP request was still in
flight. Recent Deliveries now tells the states apart and refreshes in
place while a delivery is pending.

- Rows show queued, in progress, succeeded or failed, plus the HTTP
status code
- Transport failures show as timed out, connection failed or blocked by
the outbound request policy
- Test Push Event and the 5s polling update the list without a page
reload
- Details open in a dialog, times render in the viewer's timezone

| | Before | After |
|-|-|-|
| List | <img width="600" alt="Recent deliveries before"
src="https://github.com/user-attachments/assets/c5fa2217-91d4-4278-bdd2-fc7e98f47bd7"
/> | <img width="600" alt="Recent deliveries after"
src="https://github.com/user-attachments/assets/0b91706e-ab5b-4fed-97f0-30c28e374f50"
/> |
| Details | <img width="600" alt="Delivery details before"
src="https://github.com/user-attachments/assets/04fcae63-de09-4906-96d9-bcea4e15550f"
/> | <img width="216" height="207" alt="Delivery details after"
src="https://github.com/user-attachments/assets/9c0f68a4-2dcf-4fd3-b4e0-31f4f031465f"
/> |

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

Assisted-by: Codex:GPT-6, Claude Code:claude-opus-5-5

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-20 08:52:15 +00:00
Lunny Xiao
9ed44be714 feat: record and expose SHA-256 for attachments (#39954)
Release assets and other attachments had no content digest, so tools
that download release binaries could not verify them. This records one
and shows it on the releases page in a GitHub-like asset list.

- Record the SHA-256 of each attachment while it streams to storage,
migrated release assets included
- Return it as `digest: "sha256:<hex>"` in the attachment API, the field
GitHub uses for release assets
- Lay out release assets in columns for digest with copy button,
download count, size and date, stacked under the name on narrow screens
- Rename the "Downloads" section to "Assets" and show the asset count
- Attachments uploaded before this have no digest, backfilling them is
left for a follow-up

| Before | After |
| --- | --- |
| <img width="600" alt="before-desktop"
src="https://github.com/user-attachments/assets/d6f290b4-5fba-4ee2-86c0-82c0bd77f702"
/> | <img width="600" alt="after-desktop"
src="https://github.com/user-attachments/assets/11bafe88-331d-4e96-9455-87774db539d8"
/> |
| <img width="360" alt="before-mobile"
src="https://github.com/user-attachments/assets/22a83b07-ca43-4cc6-8d2a-c1fc92a32dfe"
/> | <img width="370" alt="after-mobile"
src="https://github.com/user-attachments/assets/d013b7d1-0683-4983-9864-5dbc7844f27d"
/> |

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-20 08:47:30 +00:00
Lazizbek Ergashev
629bc3970d fix(web): redirect to the branch after applying a patch (#40450)
After applying a patch in the web editor, Gitea redirected to
`/src/branch/<branch>/__dummy_for_EditRepoFileForm.TreePath(Required)__`,
which is a 404. The patch form only sends that placeholder `tree_path`
to pass form validation, but the handler still used it as the redirect
path. It now redirects to the branch root, like cherry-pick and revert
do.

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

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-11-20 05:55:13 +00:00
silverwind
099abf5db4 test: reduce fixture setup work in Go tests (#40423)
Reduce the work Go tests spend on fixture setup, without dropping any
test or covered code. Every fixture repository reset listed and stat'ed
both trees, and many packages copied repositories or created a database
they never use.

- List the fixture repository source tree once per process
- Skip the repository copy in DB-only packages and the database in
settings-only packages
- Drop the unused repository copy and git init from migration tests
- Push LFS files last in `TestGitGeneral`, so LFS hooks don't run on
every later git command
- Link the integration test binary without DWARF

Measured locally on macOS, wall and CPU time:

| | Before | After |
|---|---|---|
| Warm fixture repository reset | 127 ms | 63 ms |
| 30 affected unit packages | 13.6 s, 72 s CPU | 10.0 s, 51 s CPU |
| Migration tests | 29.9 s, 19.1 s CPU | 13.7 s, 8.8 s CPU |
| `TestGitGeneral` | 81 s, 69 s CPU | 62 s, 54 s CPU |
| 46 API integration tests | 41.7 s | 39.0 s |
| Integration test binary relink | 8.7 s, 11.6 s CPU | 3.7 s, 5.7 s CPU
|

Assisted-by: Claude Code:claude-opus-5-5
2026-11-20 02:58:39 +00:00
bircni
b1c5fedd17 feat(pull): improve merge box, add auto_merge to PR API (#38404)
Rework the merge box after GitHub, fix auto merge edge cases, and add
`auto_merge` to the pull request API.

- Review, checks, mergeability and blocker sections that refresh while
checks run, each rendered from a `pullMergeBoxSection` instead of the
flat info item list.
- Auto merge waits out conflicts, and is canceled on close, WIP, or a
retarget or push by a non-writer.
- Bypassing branch protection needs an explicit checkbox.
- Merging follows the delete branch setting, and the timeline can
restore the deleted branch.
- Unrelated branches get their own status instead of a conflict.
- The merge API answers a merge blocked by an open dependency with 422
instead of 500.

<img width="600" alt="Merge box ready to merge"
src="https://github.com/user-attachments/assets/95dcec16-fba5-446f-81f9-5af1245c887f"
/>
<img width="600" alt="Merge box with review required and checks pending"
src="https://github.com/user-attachments/assets/640ec08e-a964-4520-85e1-5c606dfaf222"
/>

Fixes: https://github.com/go-gitea/gitea/issues/39851
Fixes: https://github.com/go-gitea/gitea/issues/24513

Assisted-by: Claude Code:claude-opus-5-5

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-19 18:53:19 +00:00
Mitrahsoft
d4101fda0c enhance: support running and unknown commit status states (#40396)
External CI can report any commit status state, but only the six known
states rendered an icon, so `running` or something like `stage-1` showed
nothing. `running` is now an official state rendered with the same
spinner as Actions, and any other state gets a fallback icon. The
combined status still treats both as pending.

A state longer than the 7-character column (e.g. `in_progress`) caused a
500. It now returns 422, as does an empty state. Widening the column
instead would need a migration, happy to do that in a follow-up if
preferred.

| Before | After |
| --- | --- |
| <img width="1904" height="654" alt="before"
src="https://github.com/user-attachments/assets/811c6a4e-7b5a-4919-8d86-ec586d9f9bfb"
/> | <img width="1919" height="675" alt="after"
src="https://github.com/user-attachments/assets/a088c70d-47fe-40c5-93f7-43d1bacfa77e"
/>|

Fixes: https://github.com/go-gitea/gitea/issues/39608
2026-11-19 11:28:12 +00:00
silverwind
c376d5d8b1 feat(actions): support cache-mode (#40343)
Support
[`cache-mode`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#cache-mode)
at workflow and job level and forward it in job payloads so runners can
enforce it. As on GitHub, a called workflow may not request more cache
access than its caller allows, otherwise the run fails as an invalid
workflow before it starts.

Enforcement needs the runner change, older runners ignore `cache-mode`.
Both can be deployed in any order.

actionslib: https://gitea.com/gitea/actionslib/pulls/33
runner: https://gitea.com/gitea/runner/pulls/1412

Assisted-by: Claude Code:claude-opus-5-5
2026-11-18 21:33:34 +00:00
silverwind
84c9f8ad76 test(e2e): add more e2e test coverage (#40429)
Add e2e coverage for browser flows that regressed before and had no
browser test.

- Web editor: preview with relative links, diff preview and proposing on
a new branch, catching CRLF in the diff and the commit
- Task lists: toggling in preview and after save with non-ASCII text
- Actions: cancel, rerun and view the earlier attempt
- File navigation: tree, go to file and tag selector on a nested file
with special characters

Assisted-by: Claude Code:claude-opus-5-5
2026-11-18 19:46:05 +00:00
Lazizbek Ergashev
0c1ebb630e fix(automerge): recheck scheduled auto merge when an official review request is cleared (#40420)
With `block_on_official_review_requests` enabled, a scheduled auto merge
stayed stuck after the last official review request was cleared, because
nothing rechecked the PR. A request can be cleared by removing a user's
request, by removing a team's request, or when the requested reviewer
submits any review, including a plain comment.

All three cases now trigger an auto merge recheck. Previously only
approvals and dismissals did. Every recheck now skips pull requests
without a scheduled auto merge before opening the git repository.

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

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-18 00:53:31 +00:00
Shivansh Garg
bf5c39b310 feat(org): add DEFAULT_TEAM_VISIBILITY instance setting (#40151)
Adds an instance-level `DEFAULT_TEAM_VISIBILITY` setting
(`private`/`limited`/`public`, default `private`) so administrators can
configure the default visibility for newly created teams when it isn't
explicitly chosen in the web form or sent via the API. Also fixes a
template bug where the "Private" radio was always force-checked on the
new-team page regardless of the actual default.

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

## Verification

Tested all three config values (absent/`private`, `public`, `limited`)
against both the web form default and the API (`POST /orgs/{org}/teams`
without `visibility`) — in each case the correct default was applied.

## Test 1: Key absent in app.ini -> falls back to "private"

<img width="3178" height="1312" alt="image"
src="https://github.com/user-attachments/assets/7ce87372-eb3e-4f03-84da-fc21ace86eca"
/>

## Test 2: DEFAULT_TEAM_VISIBILITY = public
<img width="2802" height="1348" alt="image"
src="https://github.com/user-attachments/assets/aa1af297-9557-434d-82c6-1af253eec2ab"
/>


## Test 3: DEFAULT_TEAM_VISIBILITY = limited


<img width="2778" height="1198" alt="image"
src="https://github.com/user-attachments/assets/1e66565b-c275-454a-a7d1-66d11ef3b9ee"
/>

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-17 08:15:45 +00:00
silverwind
1424a2b7c2 fix(packages): replace blakesmith/ar with an in-tree reader (#40401)
https://github.com/blakesmith/ar is unmaintained since 2019 and panics
on a negative member size (https://pkg.go.dev/vuln/GO-2026-6905), with
no fixed version. Debian packages only need a small subset of the `ar`
format, so this reads it in-tree.

- Malformed or truncated archives are rejected with a 400 instead of a
500 or a panic
- Parsing stops after the first `control.tar` member, deb(5) allows only
one

Assisted-by: Claude Code:claude-opus-5-5
2026-11-17 03:14:40 +00:00
silverwind
055105d42f fix(web): match settings page titles to the UI (#40336)
Many settings pages had a generic or missing title, so browser tabs and
history named the wrong page. Titles now use the active sidebar label,
or the page header on sub-pages, and are set once where several handlers
render the same page. The user and org webhook list headers print the
title, so they now read "Webhooks" instead of "Settings".

| Page | Before | After |
| --- | --- | --- |
| Runners, secrets, Actions general, admin job queue | Actions |
Runners, Secrets, General, Job queue |
| User and org webhooks, org options, 2FA enroll, account and keys after
a form error | Settings | Webhooks, Organization, Enroll in Two-Factor
Authentication, Account, SSH / GPG Keys |
| Admin self check, OAuth2 app edit, repo public access, repo LFS
pointer files | (none), owner/repo | Self Check, Edit OAuth2
Application, Public Access, Find pointer files |
| Admin trace, new branch protection rule, package cleanup rules |
Monitoring, Branch Protection -, Packages | Trace, Add New Rule,
Add/Edit Cleanup Rule, Cleanup Rule Preview |
| Admin webhook add and edit | Add/Update Webhook | Add/Update System
Webhook, Add/Update Default Webhook |
| Sidebar on admin queue, admin webhook edit, user OAuth2 app edit | no
highlight | Queues, Webhooks, Applications |

Assisted-by: Claude Code:claude-opus-5-5
2026-11-17 02:41:49 +00:00
Lazizbek Ergashev
8b48b45def fix: use button to replace anchor elements without href (#40338)
Elements `<a>` without `href` are not focus-able, screen readers didn't
expose it as a button.

Use `<button type="button">` for these elements, and fix what the
conversion exposed:

- Disabled reactions and the copy-content button use `aria-disabled`,
because native `disabled` suppresses their tooltips
- The random label color button gets a label
- Hover, disabled and alignment styles that only matched `<a>` apply to
the buttons
- Unpinning an issue with the keyboard works, and removing a
non-permitted "blocked by" dependency sends the right type

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

Assisted-by: Claude Code:claude-opus-5-5

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-16 17:48:41 +00:00
bircni
3f1b738f09 enhance(audit): record remaining security-relevant events (#40323)
Adds audit actions for security-relevant changes that were not logged at
all, and records a few remaining events on paths that skipped them:

- Account login prohibition (`user:status:prohibitlogin`) and the
organization setting that lets repository admins change team access
- Actions runner registration tokens issued, runners removed or
enabled/disabled, and Actions variables, for every scope
- Instance config changes, including maintenance mode
(`system:config:update`)
- Deploy token regeneration and pull mirror address changes
- Review deletion and dismissal, package removal, and release and tag
removal
- Repository restores via `gitea admin restore-repo`, OAuth2 secret
rotation on API update, and SSH keys added or removed by authentication
source sync

The authentication source SSH key sync moved from the asymkey model to
the asymkey service so it can record events.

Follow-up to https://github.com/go-gitea/gitea/pull/40317 and
https://github.com/go-gitea/gitea/pull/40322.

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-16 00:10:54 +00:00
bircni
c144668e59 fix(audit): record missing user and authentication events (#40317)
Several entry points change users, credentials or 2FA without writing an
audit event, while the equivalent web or service path does. This records
the existing actions on those paths:

- `user:create` for self sign-up, OAuth2 auto-registration, link-account
registration and `gitea admin user create`
- `user:accesstoken:add` for `gitea admin user generate-access-token`
and `user create --access-token`; `user:accesstoken:remove` for `DELETE
/api/v1/token`
- `user:twofactor:disable` for the admin "reset 2FA" option and `gitea
admin user disable-2fa`
- `user🔑ssh:add`, `user🔑gpg:add/remove` for the API
- `user📧primary`, `user📧activate`, `user:status:active` for
settings, the activation page/links and OAuth2 source sync deactivation
- `user:oauth2application:grant` when a grant's scope changes,
`user:externallogin:add` on registration via an external login
- `user:authentication:fail:twofactor` for wrong recovery codes, failed
WebAuthn assertions and 2FA during password reset

Should be backported to v28.

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-15 20:42:12 +00:00
bircni
e5b1ac76f9 fix(audit): record missing repository and content events (#40322)
Several API and background paths change repositories without writing the
audit event the web UI writes for the same change. This records the
existing actions on those paths:

- Webhook add/update/remove via the API (repository, organization, user
and system hooks)
- Branch and tag protection add/update/remove via the API
- Deploy keys and deploy tokens via the API, and deploy tokens generated
in the web UI
- Push mirror add, archive/unarchive and default branch changes via the
API
- Project create/update/delete via the API, and closing/reopening
projects in the web UI
- `repository:create` for migrations, `pr:merge` for scheduled
auto-merges, `pr:comment:create` for reviews (with `review_id` and
`review_type`) and review code comments
- `repository:delete` for repositories removed by the missing-repository
cleanup or an owner purge

Webhook, secret and OAuth2 application events now also keep the
impersonator.

Assisted-by: Claude Code:claude-fable-5-2

---------

Signed-off-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: delvh <dev.lh@web.de>
2026-11-15 13:49:58 +00:00
bircni
9bc19f2823 fix(api): do not allow renaming the Owners team (#40381)
The API accepted a new name for an organization's Owners team. The owner
team is looked up by its name, so the organization had no owner team
afterwards and its owners lost access to it.

The API now rejects the rename, as the web UI already does.

Fixes #40380
2026-11-15 12:50:48 +00:00
bircni
6579749a02 fix(repo): do not check out existing repo content during auto-init (#40376)
Plain repository creation marked a new repository as ready before its
git data, hooks and initial commit existed, and auto-init cloned the new
repository to build its initial commit on top of whatever it already
contained.

- Auto-init builds the initial commit in a freshly initialized temp
repository instead of a clone
- New repositories are inserted as being created and marked ready once
initialized, as fork, template generation, adoption and migrations
already do

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-15 11:31:40 +00:00
bircni
0a66642da0 fix(repo): limit the commit status fields returned by repo search (#40377)
The web repo search response embedded the whole commit status model
although the dashboard only uses its state and target URL. It now
returns just those two fields.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-11-15 11:27:05 +00:00
silverwind
3317a31c22 fix(actions): resolve $/ steps against the job's workflow source (#40075)
GitHub resolves `uses: $/{path}` against the repository and commit of
the job's workflow file, not the triggering ones. When those differ, as
with reusable workflows from elsewhere or owner and global workflows:

- such steps are pinned to `self:{repo}/{path}@{sha}` in the runner
payload
- `$/` steps with expressions in their path fail the run as an invalid
workflow, as they can't be pinned safely and GitHub rejects them too

Same-source jobs keep `$/`, so older runners are unaffected.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
2026-11-14 07:15:46 +00:00
Basavaraj S m
eaa4fe918d fix(api): hide org roles from non-members (#40042)
`GET /users/{username}/orgs/{org}/permissions` returned a user's team
roles to anyone who could see the org, revealing concealed members and
their roles. Now only the user, unrestricted org members and site admins
get the real answer, everyone else gets the non-member response:

- Outsiders get no roles, for public members too.
- Restricted members only get their own roles.
- Public-only tokens get none, and site admins need an `all`-scoped
token.

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-13 19:37:56 +00:00
Shivansh Garg
1f614953a2 enhance: allow admins to force user activity visibility (#40002)
Adds `[service] FORCE_USER_ACTIVITY_VISIBILITY` so admins can force the
activity of all users to be `public` or `private`, e.g. for company
instances that require public activity.

- When the value changes, the next start overwrites the "Hide Activity"
setting of all users. New users get the forced value too.
- The "Hide Activity" checkbox is disabled with an explanatory tooltip
while forced, and `PATCH /api/v1/user/settings` rejects a conflicting
`hide_activity` with 422.

| Before | After |
| --- | --- |
| <img width="122" height="17" alt="before"
src="https://github.com/user-attachments/assets/d138acec-5d40-4a0a-881c-0097e5197a8f"
/> | <img width="258" height="46" alt="after"
src="https://github.com/user-attachments/assets/7e8f7d1b-3303-4473-8d3b-aa35ef8fb20d"
/> |

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

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-11-13 17:32:29 +00:00
silverwind
53aafd7ee1 fix(actions): include previous values in edited payloads (#40179)
Actions `edited` payloads omitted `changes`, so workflows could not see
previous values. Issue/PR title and body edits now carry
`changes.title`/`changes.body`, base branch changes add
`changes.base.ref`/`changes.base.sha` (and `changes.ref` now holds the
old branch, not the new one), release edits carry
`changes.name`/`changes.body`.

_Written by Claude (Opus 5.5)._

---------

Co-authored-by: Claude (Opus 5.5) <noreply@anthropic.com>
2026-11-13 08:43:13 +00:00
Rafail Giavrimis
38389f00be feat: unify code search, add search API (#39403)
Adds GitHub-style code search endpoints and makes code search behave the
same in the web UI and the API, whether it runs on git grep, bleve or
Elasticsearch.

- `GET /repos/{owner}/{repo}/code/search` searches any branch, tag or
commit with git grep, so it works without the code indexer.
- `GET /search/code` searches the default branches of all accessible
repositories with the code indexer.
- One query syntax everywhere: every term must match a file's content or
path, case-insensitively. It supports `"phrases"`, `/regexp/` (git grep
only) and the `path:`, `language:`, `repo:`, `user:` and `org:`
qualifiers. Invalid queries return an error.
- All engines apply the same include, exclude, vendored and size rules,
and return every match. The web UI shows them as multiple snippets per
file with the matched text highlighted.

<img width="359" height="295" alt="image"
src="https://github.com/user-attachments/assets/59b7aa66-b1dc-4938-9ef9-66668ae08d7c"
/>

Fixes: https://github.com/go-gitea/gitea/issues/10706
Fixed: https://github.com/go-gitea/gitea/issues/15841
Fixes: https://github.com/go-gitea/gitea/issues/31375
Related: https://gitea.com/gitea/gitea-mcp/issues/280
Docs: https://gitea.com/gitea/docs/pulls/615

AI usage disclosure: Yes, I used AI to write code, review changes and
verify the factuality of the overview I provided. I take full
responsibility for the code in this PR.

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-13 07:24:37 +00:00
Kirill Kamakin
dc9a2aefdc fix(actions): keep runner_name after ephemeral runner removal (#39725)
Jobs that ran on ephemeral runners lose `runner_name` in the
`workflow_job` completed webhook and the jobs API, because the runner
row is deleted when the task finishes. GitHub keeps both `runner_id` and
`runner_name`, and GARM ignores completed jobs without a name, holding
the runner slot until its periodic cleanup.

The name is now stored on the task when claimed, and a migration
backfills tasks whose runner row still exists.

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2026-11-13 01:18:57 +00:00
silverwind
9f93e8d808 test: add e2e tests for comments, file tree, actions and branch protection (#40313)
Add e2e tests for flows that had no browser coverage: editing and
quote-replying an issue with an uploaded image, file tree and go-to-file
navigation, the Actions run view and workflow dispatch, and branch
protection rules with their priority.

The tests exposed bugs that are fixed here:

- Quote reply into an empty comment box left the Comment button disabled
- Removing an uploaded attachment did not update the comment buttons
- Going back from a file opened via the file tree to the initially
loaded page kept showing the other file

Assisted-by: Claude Code:claude-opus-5-5
2026-11-12 07:12:55 +00:00
Shivansh Garg
aa073fb1be fix(web): avoid compare output route collisions (#40307)
Allow compare refs named diff or patch to use the normal compare page
while preserving explicit .diff and .patch downloads.

Compare refs ending in diff or patch were incorrectly matched as raw
.diff/.patch routes. This caused normal compare pages such as
main...diff and main...patch to return an empty or invalid response.

The route matching is now constrained so valid raw diff/patch downloads
continue working while branches named diff or patch use the normal
compare page.

Assisted-by: Agent:GPT-5.6 Luna

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

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-11-11 17:53:39 +00:00
wxiaoguang
b3422c0920 refactor: clean up error system (#40328)
1. `ctx.ServerError("LogMessage", err)` is very messy and useless. When
the log is printed, it already contains the caller's file and line
number
2. `ctx.NotFound(nil)` and `ctx.NotFound(err)` were abused a lot, now
only `ctx.NotFound()`

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-11 17:07:57 +00:00
silverwind
03fc2bdcc8 fix(repo): require the unit in AccessibleRepositoryCondition (#40059)
`AccessibleRepositoryCondition(user, unitType)` now requires the repo to
have the requested unit enabled and not globally disabled, consistent
with the per-repo permission checks. This affects code search, Actions
run listings, LFS object reuse, recently pushed branches and org project
milestones.

Written by Claude.
2026-11-11 12:55:04 +00:00
silverwind
d399f844e6 test: fix the login tab order e2e test in macOS WebKit (#40316)
The login tab order test fails in WebKit on macOS, so `make test-e2e`
fails locally on every Mac. CI on Linux is unaffected.

- macOS WebKit moves Tab focus only between text fields, plus buttons
and checkboxes when the system keyboard navigation setting is on, and
never to links, like Safari. Option+Tab reaches every element there and
acts as Tab in Linux WebKit, so the test presses Alt+Tab in WebKit.
- Headless WebKit applies the username `autofocus` late, which pulled
focus back from the password field. The test now waits for the autofocus
first, which also covers it.

Follow-up to https://github.com/go-gitea/gitea/pull/40081

Assisted-by: Claude Code:claude-opus-5-5
2026-11-10 20:07:28 +00:00
Gaurav Dubey
d5ce1cad7f fix(indexer): reindex issues when their projects change (#40299)
With the bleve, elasticsearch or meilisearch issue indexer, a keyword
search filtered by project matched issues by the projects they had when
they were last indexed, so newly added issues were missing and removed
ones still showed up.

- Reindex an issue when its projects change, using `IssueChangeProjects`
from https://github.com/go-gitea/gitea/pull/30205.
- Reindex the issues of a deleted project, so the "No project" filter
finds them again.

Entries that are already stale are corrected on the issue's next change
or an index rebuild.

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

Assisted-by: Claude Code:claude-opus-5-5

---
🤖 Opened with [Superhuman](https://github.com/gaurav0107/superhuman), an
open-source contribution agent.

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-10 19:26:12 +00:00
Yonghun Shin
2ef5b7623b fix(packages): generic package deletion ignores terraform state lock and latest version (#40302)
`IsLocked` and `IsLatest` in `services/packages/terraform/state.go`
return early when the package **is** a terraform state (`==` instead of
`!=`), so the `OnBeforeRemovePackageAll` /
`OnBeforeRemovePackageVersion` guards never fire. As a result, deleting
through the generic package API (`DELETE
/api/v1/packages/{owner}/terraform/{name}[/{version}]`) or the web UI
ignores the state lock and allows removing the latest state version,
while the terraform state endpoints reject both.

Changes:

- Flip the type check in `IsLocked` and `IsLatest`.
- `DeleteState` (terraform state `DELETE` endpoint) relied on the bug:
after checking the lock it removed every version one by one with
`RemovePackageVersion`, including the latest. With the guard fixed, it
failed with 500 partway through and left a half-deleted state (the
existing `TestPackageTerraform` subtests catch this). It now calls
`RemovePackage`, which checks the lock and deletes everything in one
transaction.
- The generic package delete API used `APIErrorInternal` for every
error, so the guard errors became 500. It now uses `APIErrorAuto`, which
returns 422 for these.
- Added a `GenericPackageAPI` subtest to `TestPackageTerraform`:
deleting an older version works, deleting the latest version or a locked
state returns 422, and deleting an unlocked state works. It fails on
current `main`.

Tested locally with `go test -run '^TestPackage' ./tests/integration`
(SQLite): all pass.

AI disclosure: I used an AI assistant (Claude) to find the bug, trace
the code paths, and draft the change and this description. I reviewed
the change and ran the tests myself.

Signed-off-by: choam2426 <choam2426@gmail.com>
2026-11-10 17:10:59 +00:00
Gaurav Dubey
1fcb6b4cd6 fix(packages): rebuild repository index after removing a package (#40306)
Deleting a package or a package version from the web UI, the admin panel
or `DELETE /api/v1/packages/...` removed the database rows but never
rebuilt the Debian, Alpine, RPM or Arch repository index, so clients
kept seeing the deleted version until something else triggered a
rebuild. Only the registries' own delete endpoints and the cleanup task
rebuilt it.

https://github.com/go-gitea/gitea/pull/22810 was closed in favor of
`OnBeforeRemovePackageVersion`, but that hook runs before the version is
gone, so it can't refresh the index. This adds an `OnAfterRemovePackage`
hook and rebuilds the owner's repository files there, the same way the
cleanup task does.

Deleting the last RPM of a group also removed the repodata of all other
groups of the owner. Now only the emptied group's files are removed.

Fixes: https://github.com/go-gitea/gitea/issues/32830
Fixes: https://github.com/go-gitea/gitea/issues/40304
Fixes: https://github.com/go-gitea/gitea/issues/40305

---
🤖 Opened with [Superhuman](https://github.com/gaurav0107/superhuman), an
open-source contribution agent.

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-10 16:29:39 +00:00
wxiaoguang
d1d702bea9 refactor: user error system (#40308)
Introduce "FlashErrorAuto" for "XxxErrorAuto" family and simplify the
error handling logic.

* Use ErrorUnwrapForHTML for web error messages 
* Use ErrorUnwrapForUser for api error messages
* Make Flash message can take up to about 3000 bytes

Next step: completely refactor "ctx.ServerError"

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-10 16:29:36 +00:00
Shivansh Garg
640cd615c4 feat: restrict pull/issue creation on access basis (#40069)
Adds a repository-level **"Restrict to collaborators"** option under the
Issues and Pull Request unit settings. When enabled, only users with
collaborator access to the base repository (owner, team members, or
explicit collaborators) can open issues or pull requests against it.

Public repositories often need to be visible/cloneable by everyone, but
owners may want to limit who can open pull requests (e.g. restrict to an
internal team while still keeping the code public)

* Fixes: https://github.com/go-gitea/gitea/issues/40015
* Fixes: https://github.com/go-gitea/gitea/issues/31890
* Fixes: https://github.com/go-gitea/gitea/issues/28021
* Fixes: https://github.com/go-gitea/gitea/issues/14801

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-11-10 00:53:49 +00:00