Registering a runner was not recorded in the audit log, so a new machine
that can pick up jobs and their secrets left no trace. Enabling and
disabling a runner were both logged as a generic "update", and editing a
runner's description was not recorded at all.
This adds a `runner:register` event for every scope. It is attributed to
the Gitea Actions system user and includes the runner's IP address.
Enabling and disabling become separate `runner:enable` and
`runner:disable` events, and `runner:update` now covers description
edits. Runners removed automatically by cleanup are not recorded,
because ephemeral runners would flood the log.
Commit verification skipped the salt that OpenPGP v6 signatures (RFC
9580) hash before the data, so v6-signed commits never verified. Use
go-crypto's `PrepareVerify`, which adds it. Post-quantum ML-DSA
signatures (RFC 9980) require v6 keys, so they now verify too.
Assisted-by: Claude Code:claude-opus-5-5
Since #35487 (1.25) the repo archive download is served by streaming
mode.
Leftover archives in `data/repo-archive` or the `repo-archive/` storage
prefix can be deleted.
Docs: https://gitea.com/gitea/docs/pulls/654
---------
Co-authored-by: silverwind <me@silverwind.io>
## TL;DR:
For custom-init markdown editors, do nothing. For non-custom-init
markdown editors, change from an imperative scan to a declarative setup.
## Longer version
As part of the `data-global-init` migration effort, this moves
ComboMarkdownEditor's automatic setup onto `data-global-init`.
### Before
`initGlobalComboMarkdownEditor()` ran a one-off startup sweep of its
own: `queryElems(document, '.combo-markdown-editor:not(.custom-init)',
...)`. The editor template relied on that page-wide selector, with the
`custom-init` class as an exclusion, rather than declaring its own
setup.
### After
- The editor template marks its root element with
`data-global-init="initComboMarkdownEditor"`, and the sweep is replaced
by a registered handler, like other migrated components.
- The attribute goes only on editors without `CustomInit`. `CustomInit`
editors are unchanged: they get no attribute, and their page code sets
them up as before.
- Setup now goes through the shared observer, so the editor follows the
same rules as every other `data-global-init` component, including
elements added after page load.
### Why
- The template now names its own setup:
`data-global-init="initComboMarkdownEditor"` leads straight to the
registered handler. Before, nothing in the template said how the editor
was set up, and the `custom-init` class only meant something because of
a selector in `common-form.ts`.
- It follows the guidance in `modules/observer.ts`, which recommends
`registerGlobalInitFunc` over selector-based setup as "less efficient
and less maintainable", and removes one of the `queryElems(document,
...)` sweeps that `utils/dom.ts` marks for refactoring.
- The editor no longer needs its own page-wide query at startup: it's
picked up by the observer's single initial pass, like the other
`data-global-init` components (55 templates use it today).
### Notes
- Editors are now set up by the observer's initial sweep, which runs
after the page-specific init code rather than before it. Every direct
editor lookup (`getComboMarkdownEditor` in `repo-release.ts`,
`repo-issue-edit.ts`, `repo-issue.ts` and the monospace toggle in
`ComboMarkdownEditor.ts`) runs on a user action, so none is affected.
- This is the first step toward removing `CustomInit` entirely. That
also needs JS-only options moved into presets and setup made idempotent,
which are separate changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
`GET /repos/{owner}/{repo}/pulls/{index}/files` parsed every file's
patch on each request, then returned one page. Stop parsing after the
last file of the requested page.
Median HTTP response time in ms for a 2,414-file PR, 30 files per page:
| Page | Before | After |
|---|--:|--:|
| 1 | 567 | 319 |
| 41 | 563 | 457 |
| 81 (last) | 561 | 556 |
Assisted-by: Claude Code:claude-opus-5-5
Runners picked the waiting job that became ready first, so a job
released by `needs` queued again behind jobs of newer runs, and a run
with several stages waited out the backlog once per stage. Runners now
pick waiting jobs in the order their runs were triggered, then by job
id, so a run keeps its place across its stages, including reusable
workflow children and dynamic matrix jobs created once their `needs`
finish. A rerun is a new trigger and queues behind. Under load, a new
push waits longer for its first job, and jobs released late by approval
or a concurrency group go ahead of newer runs. The job queue page lists
jobs in the same order, and the `pickup` index becomes `(task_id,
status, run_attempt_id, id)` to serve it.
Fixes: https://github.com/go-gitea/gitea/issues/40430
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Conda (and libmamba) require every valid channel to serve
`noarch/repodata.json` and `noarch/repodata.json.bz2` even when empty,
while treating 404 on platform-specific subdirs as empty. Previously
`EnumeratePackages` returned 404 whenever no package files existed for
the requested subdir, causing `conda install` to fail with a 404 on
`noarch/repodata.json` whenever a channel only contained
platform-specific packages (e.g. `linux-64`).
Return HTTP 200 with an empty `RepoData` payload when the requested
subdir is `noarch` and no files exist, while keeping 404 for empty
non-`noarch` subdirs.
Fixes: https://github.com/go-gitea/gitea/issues/25554
Assisted-by: Claude Code:gemini-4-neon
The forgot-password page answers an unknown email with the "reset mail
sent" confirmation, which is the right call for not revealing accounts.
But for an existing local account, a second request inside the 180
second `MailResendLimit_` window sets `ResendLimited`, and because
`IsResetRequest` is already set the template renders the reset form
again instead of the confirmation. So an anonymous client can send an
address twice and tell from the second response whether it belongs to an
account. It needs the mail service enabled, nothing else.
This makes the resend-limited branch set the same `IsResetSent` /
`ResetPwdCodeLives` data as the normal and unknown-user paths. The
resend limit still holds, so no extra mail goes out.
It's the same kind of difference #36002 removed from the login errors
(#35984), just on the reset page.
Tested on a local instance with SQLite and a dummy mailer: on v28.4.0
and on main the repeat request showed the form while an unknown address
showed the confirmation; with this change all of them show the
confirmation. The `routers/web/auth` package tests pass on main and
`release/v28` with the change. It applies to `release/v28` too if you
want it backported.
I used AI tools to help find this and draft the change; I've gone over
the diff and the code path myself.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Update dependencies. chartjs-plugin-zoom 3 drops Hammer.js, which
shrinks the contributors chart bundle by about 14 KB.
Adapt to the updates: use rolldown's `bundlerTimings` instead of the
deprecated `pluginTimings`, drop an asciinema-player style override that
3.19 makes redundant, and retry the Redis session backend's startup ping
like the cache and queue setup do, because go-redis 9.24 gives up on a
refused connection sooner.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
A huge `page` value made `(page-1)*pageSize` wrap to a negative int.
`PaginateSlice` then panicked with a slice-bounds error (e.g. the cron
and tags APIs), and `ListOptions.GetSkipTake` caused an index panic in
the pull request commits and files APIs. `PaginateSlice` now compares
the page against `len(list)/pageSize`, and `ListOptions` caps the page
so the offset stays in range.
---------
Co-authored-by: silverwind <me@silverwind.io>
Switch `SyncPullMirror` to `globallock.TryLock` (matching
`services/cron/tasks.go`) so duplicate requests return immediately when
a sync for that repository is already in progress.
Fixes: https://github.com/go-gitea/gitea/issues/40549
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
The activity page summed per-commit `git log --numstat`, so a renamed
file counted as an extra `old => new` path and changes that landed
through merge commits were missed. Like GitHub's Pulse, the changed
files, additions and deletions now come from the default branch's net
diff over the period, so git detects renames and changes reverted within
the period no longer count.
`GetCodeActivityStats` on an M3 Max, median of 6 runs:
| Repo | Period | Before | After |
|---|---|---|---|
| gitea | week | 40 ms | 40 ms |
| gitea | year | 2.06 s | 0.51 s |
| golang/go | week | 524 ms | 155 ms |
| golang/go | year | 4.54 s | 0.75 s |
Refs:
https://github.com/go-gitea/gitea/pull/40569#issuecomment-7231088642
Assisted-by: Claude Code:claude-opus-5-5
Follower and following lists, including the counts in the profile
sidebar, filter private users through a `team_user` self-join that grows
with the number of teams a signed-in viewer shares an org with. Use
`org_user`, which holds the same memberships with one row per user and
org.
Median `GetUserFollowing` time in ms on synthetic data, before → after:
| Viewer | SQLite | MySQL | PostgreSQL |
|---|--:|--:|--:|
| In 10 teams of a large org | 485 → 25 | 758 → 29 | 204 → 35 |
| In 1 team of a large org | 23 → 13 | 0.6 → 0.6 | 13 → 8 |
| In no team | 3.1 → 3.1 | 1.3 → 1.3 | 131 → 6.5 |
| In 180 small orgs | 3.0 → 3.0 | 3.2 → 1.5 | 16 → 19 |
Assisted-by: Claude Code:claude-opus-5-5
Pull request pages recomputed the doer's repository permission up to
five times per request. Reuse `ctx.Repo.Permission` and cache lookups on
other repositories, so forks are resolved once per request.
| Merge box | Queries | MariaDB | +0.5 ms DB latency |
|---|---|---|---|
| Open PR | 40 → 32 | 57 → 56 ms | 125 → 118 ms |
| Closed PR | 37 → 24 | 51 → 43 ms | 109 → 89 ms |
| Fork PR | 52 → 39 | 78 → 69 ms | 159 → 146 ms |
Assisted-by: Claude Code:claude-opus-5-5
Deleting a team that includes all repositories kept its `team_repo` and
`access` rows, so former members kept their access to the team's
repositories. `DeleteTeam` relied on `RemoveAllRepositoriesFromTeam`,
which skipped such teams.
`RemoveAllRepositoriesFromTeam` now always removes the team's
repositories, and the "remove all" action uses the new
`RemoveSpecifiedRepositoriesFromTeam`, which keeps the guard.
Regression of https://github.com/go-gitea/gitea/pull/19158
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
The two 2FA login forms relied on the deprecated
`RenderWithErrDeprecated` path, which re-rendered the whole page on a
wrong code and made the submit button send a duplicate request on a
second click. Migrate both forms to `form-fetch-action` and return JSON
errors from the handlers, so the framework's built-in in-flight guard
blocks duplicate submissions and errors are shown as toasts.
Fixes: https://github.com/go-gitea/gitea/issues/27427
Assisted-by: OpenCode:hy4-flash-free
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
A relative `APP_TEMP_PATH` was resolved against the process working
directory, which differs between Gitea processes. `gitea hook` runs from
the bare repository, so its startup check failed and every push was
rejected. It now resolves against `APP_DATA_PATH`, like the other data
paths.
Fixes:
https://github.com/go-gitea/gitea/pull/40448#discussion_r4689040364
Docs: https://gitea.com/gitea/docs/pulls/661
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
`repoGetArchive` declared `application/json` in the Swagger 2 spec while
actually serving an archive, which made generated API clients fail on
content-type validation. Declare it as `application/octet-stream` with a
file schema, as already done for `repoGetRawFile`, so the body also
appears in the OpenAPI 3 spec.
The shared `error` response described its `message` and `url` fields as
headers, so clients could not decode error bodies. Declare it as a JSON
body using the `APIError` struct.
Fixes: https://github.com/go-gitea/gitea/issues/21997
Assisted-by: OpenCode:hy4-flash-free
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Query-string tokens end up in proxy and access logs, so
`DISABLE_QUERY_AUTH_TOKEN` now defaults to `true`. The `token` and
`access_token` query parameters are ignored on the API and on web routes
that accept tokens, like raw, media, archive and attachment downloads.
## ⚠️ BREAKING ⚠️
Clients that send a token as `?token=` or `?access_token=` are treated
as anonymous. Send it in the `Authorization: token <token>` header
instead, or as the basic auth username (`https://<token>@host/...`)
where only a URL can be configured. Admins can restore the old behavior
for now with `[security] DISABLE_QUERY_AUTH_TOKEN = false`, which logs a
deprecation warning at startup.
Docs: https://gitea.com/gitea/docs/pulls/665
Assisted-by: Codex:gpt-6-astra
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: silverwind <me@silverwind.io>
Git's `--numstat` output is tab-separated, but the code activity parser
split each line on whitespace. Two changed files whose names share a
first word, such as `docs/release notes.md` and `docs/release plan.md`,
were deduplicated into one entry and undercounted on the activity page.
Parse the line by its tab separators so the full path is preserved.
The contributors graph had a similar parser bug: an empty commit made it
drop the following commit, and an empty tip commit was skipped. Both
parsers now use NUL-prefixed separators that can't collide with commit
metadata.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Structural cleanups in the Actions code, plus fixes that align run
behaviour with GitHub Actions.
- Load a reusable caller's ancestor chain once for both expansion checks
and its dispatch inputs.
- Extract the rerun job reset and pass-through rules so they can be unit
tested.
- Share the gate a job passes once its `if:` holds (max-parallel slot,
invalid `runs-on`, concurrency group) between run insertion, rerun and
approval. The job emitter keeps its own, which also defers to groups
admitted in the same pass.
- Resolve the scope of every actions settings page, secrets included, in
one place. The variables and secrets pages dereferenced a nil context
when the org header failed to render.
- Move the API handler interface to the API router, and record runner
bulk-action audit events after the commit.
- Split the 1500 and 2200 line handler files and move the actions
converters into their own file, without code changes.
- Partial reruns load a reusable workflow at the previous attempt's
commit, full reruns resolve its ref again.
- Reject loops through the root workflow at validation.
- Compare concurrency groups case-insensitively and keep runs awaiting
approval out of them until approved.
- Fail-fast ignores failures carried over from an earlier attempt, and
reruns fail a job with an invalid `runs-on`.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
`merge_when_checks_succeed` sounds like it waits for all checks, but
auto-merge only waits for branch protection requirements like required
status checks and approvals, and merges right away when none apply.
Document that in the API model without changing behavior, matching
GitHub's auto-merge and Renovate's `platformAutomerge` docs, which both
rely on required checks.
Fixes: https://github.com/go-gitea/gitea/issues/35756
Assisted-by: OpenCode:hy4-flash-free
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Unify the glob help texts on the protected branch, protected tag and
webhook settings pages. All glob syntax links point to the gobwas/glob
syntax section with matching link text. The file pattern examples
replace `.drone.yml` and `/docs/**/*.txt`, which never matched because
changed paths have no leading slash, with `.gitea/workflows/**` and
`CODEOWNERS` for protected files and `docs/**` and `**.md` for
unprotected files.
Links and code markup move from the translations into the templates, and
the English texts are shortened. The changed strings use new keys, so
other locales fall back to English until they are translated instead of
rendering mismatched placeholders.
<img width="838" height="465" alt="Before and after of the glob help
texts"
src="https://github.com/user-attachments/assets/beabc67d-c8be-4926-ac72-31aa4b726f5b">
Fixes: https://github.com/go-gitea/gitea/issues/39694
Assisted-by: OpenCode:hy4-flash-free
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Gitea supports git 2.34 and newer, but with git 2.34.1 `go test
./modules/git/` panics in `TestReadingBlameOutput/sha256` (nil pointer
dereference), which aborts the rest of the package, and `services/pull`
fails its `*-MergeTree` cases with `exit status 129`. These tests use
sha256 repositories, `cat-file --batch-command` and `merge-tree
--write-tree`, which production code only uses when `DefaultFeatures()`
says git is new enough (2.42, 2.36 and 2.40).
Those cases now skip on the same `DefaultFeatures()` flags, as the
check-attr tests in `modules/git/attribute` already do. With git 2.34.1
both packages failed before; now they pass with those cases skipped, and
`make test-backend` passes as a whole. With git 2.42.0, 2.43.0 and
2.56.1 nothing is skipped; with 2.41.3 only the sha256 cases are.
Related: https://github.com/go-gitea/gitea/pull/39565
Assisted-by: Hermes Agent:claude-opus-5-5
A cancelled Actions job is stored as a `failure` commit status, so the
merge box reported a job that was only stopped as failing.
The merge box now reads the live Actions job status and counts such
checks as "canceled" in the summary, with the grey stop icon. When
nothing actually failed, the header reads "Some checks haven't completed
yet" instead of "Some checks were not successful".
Like GitHub, the stored commit status stays `failure`: commits keep the
red X, required checks still block the merge, and the API is unchanged.
Cancelled checks are listed in the failing group.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
The glob compiler wrote a backslash followed by the escaped character
into the generated regexp, so `\d`, `\w`, `\s` and `\b` were parsed as
regexp constructs instead of the literal character. `a\d` compiled to
`^a\d$` and matched "a5" instead of "ad"; `a\b` became a zero-width word
boundary. Escaping a character Go does not recognise, e.g. `\C`, made
the pattern fail to compile, and protected branch rules then fell back
to matching the raw rule text literally.
Escape only ASCII punctuation, which Go always reads as a literal, and
write letters, digits and non-ASCII characters as-is. This matches
gobwas/glob and act. Rules that relied on `\d` matching a digit since
https://github.com/go-gitea/gitea/pull/35478 now match a literal `d`.
Assisted-by: OpenCode (DeepSeek V4.1 Flash)
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Repository runner tokens created by `gitea actions generate-runner-token
--scope owner/repo` before 1.23, or by the repository API before 1.22.2,
kept the owner ID. Migration 314 skipped this table, so these tokens
stay valid but are hidden in the settings and survive a reset. A
migration now normalizes the active ones.
Registering a runner also wrote the token back as active, which could
undo a concurrent reset. That write and the unused `UpdateRunnerToken`
are removed.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
`FormStrings` only parsed the form with `ParseMultipartForm`, which
returns `http.ErrNotMultipart` for urlencoded bodies, so it returned nil
unless something else had parsed the form first. The CSRF check used to
do that, and since it was removed the "Associate accessible OIDs" button
on the LFS pointers page sends no OIDs and fails with a 500. The global
multipart parse in the web and API contexts is also removed, form
helpers now parse on demand.
Fixes: https://github.com/go-gitea/gitea/issues/40551
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Several markup processors stopped scanning a text node after skipping
one match. An external issue or code preview URL hid later local ones,
an SSH remote like `git@host:org/repo.git` hid a later email address, a
short link with a disallowed scheme hid later short links, and a text
node ending in an ellipsis left all its URLs unlinked.
The processors now continue past skipped matches. Only a URL in the last
word of a text node ending in an ellipsis is treated as truncated.
Fixes: https://github.com/go-gitea/gitea/issues/40505
Assisted-by: OpenCode:gemini-4-neon
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: silverwind <me@silverwind.io>
Package registries walk an uploaded archive to find its metadata,
decompressing every entry on the way with no limit, so a small crafted
archive can burn minutes of CPU. Bound the bytes read while locating
metadata to `max(512 MiB, MAX_DECOMPRESSION_RATIO × upload)`.
The ratio (default 200) scales with the upload so large regular packages
still pass, and `-1` disables the bound. The `.tar.gz` parsers open
uploads through one shared reader that applies it. Parsers already
bounded (npm, debian, helm) are left unchanged.
Docs: https://gitea.com/gitea/docs/pulls/647
Assisted-by: Claude Code:claude-opus-4-8
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Merge and squash now run `git merge-tree` and `git commit-tree` in the
base repository and push the commit to itself, instead of building a
temporary repository per merge, which made merges take over 10 s on NFS
(https://github.com/go-gitea/gitea/issues/39410). Rebase styles,
fast-forward-only and git older than 2.40 are unchanged.
Commit and tag messages are cleaned up in one place like `git commit`
does, and merge-specific `[git.config]` overrides no longer apply to
merge and squash.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>