Repository navigation
web: migrate the commit compare page to React - #8534
Merged
Merged
Conversation
3 of 4 tasks
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 14, 2026 05:43
2bd0113 to
a1f3d6b
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
3 times, most recently
from
November 14, 2026 13:23
d71211d to
f762988
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
3 times, most recently
from
November 14, 2026 17:11
9a6998a to
55dd177
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:00
6e317a2 to
9850d91
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:34
c1366fa to
f7efb35
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 14, 2026 20:21
4ae184d to
93a531d
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 14, 2026 21:47
2fae4eb to
ae8bda3
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
3 times, most recently
from
November 14, 2026 23:00
afcedfd to
39f48c8
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
6 times, most recently
from
November 15, 2026 22:18
61df07b to
6e192af
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 16, 2026 00:46
2552c00 to
ed6df3d
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
2 times, most recently
from
November 16, 2026 02:24
ac33d0b to
af070cb
Compare
unknwon
force-pushed
the
compare-react-flamego
branch
from
November 16, 2026 03:07
af070cb to
6cae75a
Compare
unknwon
marked this pull request as ready for review
November 16, 2026 03:48
unknwon
force-pushed
the
compare-react-flamego
branch
from
November 16, 2026 03:52
6cae75a to
aa4b843
Compare
The commit page keeps its header and renders DiffWorkspace, which takes the patch with the old and new revisions, so other pages can show a diff the same way. The commit page does not change.
The comparison of two commits, e.g., of a push in the activity feed, is now
a React page backed by /api/web/{owner}/{repo}/compare/{before}...{after}.
It lists the commits in the range and shows the diff in DiffWorkspace, the
same view as the commit page, with the raw diff served at the same path
with a ".diff" suffix.
Looking up a full-length commit ID that does not exist now reports the
revision as missing instead of failing, so such links return 404.
Log and RevList started two git processes for every commit they list, which takes seconds for a few hundred commits.
The heading counts every commit, the list shows the first 10 until "Show more", and a cut-off list links to the full history.
The compare page is mostly read for its diff, so each commit takes one line with its author, time and SHA, as on GitHub.
unknwon
force-pushed
the
compare-react-flamego
branch
from
November 16, 2026 04:49
f0fc805 to
1be923d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Migrates the comparison of two commits (
/{owner}/{repo}/compare/{before}...{after}) to React. This is the page the activity feed and push notifications link to. It is backed byGET /api/web/{owner}/{repo}/compare/{before}...{after}, and the raw diff is served at the same path with a.diffsuffix.Two commits:
DiffWorkspace, which takes the raw diff and both commits. The commit page only keeps its header. No visible change.DiffWorkspacefrombeforetoafter. Unified and split, whitespace options, the file tree and "Expand all lines" all work as on the commit page, and expanding reads the files atbeforeandafter./compare/master...feature) still go to the pull request compare page.CommitListtakescompact, which lists the commits without day headings, each on one line: the title, then the avatar, author and time, then the SHA, without the copy and browse buttons. Belowsmthe author and time go under the title. Only the compare page uses it, and the commit history keeps its two-line rows..diffno longer lists commits at all.LogandRevListread the commits they list with onegit cat-file --batchinstead of two processes per commit. This also speeds up the commit history and every other commit list.RawDiffOptions.Basediffs from a base commit instead of the parent. A commit that is not in the repository gets 404 on both the compare page and its.diff.CompareDiffhandler andrepo/diff/page.tmpl.commits_table.tmplstays for the pull request pages.repo.commits.n_commitandrepo.commits.n_commits. DocumentedDiffWorkspaceinweb/DESIGN.md.Behavior changes from legacy
Screenshots
Comparing two commits
Expanded lines of
long.go, with search in diffDark
Split
No changes
Commit page, unchanged
300 commits, first 10 shown
300 commits, after "Show 40 more commits"
300 commits, dark
Checklist
Test plan
go test ./cmd/gogs/internal/web/ ./internal/git/ ./internal/route/...passes.TestRequireViewAccesscovers both new endpoints,TestRepository_RawDiffcoversBase, andTestRepository_CatFileCommitcovers a missing full-length ID (it fails without the fix).moon run gogs:lintandmoon run web:lintreport 0 issues.-tags prodbuild with SQLite. Seed: alice owns the publicwidgetsand the privatesecret. bob can readsecret, and carol has no access.widgetscompare returns the commits newest first..diffreturns the raw diff, also with?whitespace=ignore-all. A missing SHA on either side gets 404 on both endpoints. carol gets 404 onsecret, and bob gets 200./compare/master...masterstill reaches the legacy pull request compare page.?style=split), and expanded all lines oflong.go, which fetched/raw/{before}/…and/raw/{after}/…. Opened an equal range and an unknown SHA (404). Rechecked the commit page: split mode, collapse and expand all, and line expansion against the parent. No sideways scroll at 375.mainafter web: migrate the repository commit history pages to React #8533, rebuilt with-tags prodand rechecked in the browser. The compare page shows "2 commits 6a7956f...09880f1" with 5 files, +7 and -4, matchinggit diff --stat -M. "Expand all lines" onlong.gofetched/raw/{before}/long.goand/raw/{after}/long.gowith 200, and search in diff jumps to the change..diffistext/plain, an equal range shows "No commits found", and an unknown SHA gets 404 from the API and.diff. With the repository private, signed out and bob get 404 from the API and.diff, and alice gets 200.scrollWidthis 375 at 375px. The commit page still shows "3 changed files" in unified and split.long-historybranch with 300 commits.TestCompareRange_ListCommitscovers 51, 50 and 3 commits and the push of the default branch, and fails without the cap. The API returns 50 commits, newest first, withtotalCommits300, for both{base}...{tip}and the empty ID. Listing 250 commits took 10s before thecat-file --batchchange and 0.2s after, and the commit history API also takes 0.2s. In the browser, the heading says "300 commits" and the list shows 10 commits and "Show 40 more commits". Clicking it shows 50 and the cut-off note, and "View the full history" opens/commits/{tip}. The 2-commit range shows no button and no note.scrollWidthis 375 at 375px.scrollWidthis 375 at 375px.