Skip to content

PR files: github.com commit box with Prev / Next for a single commit - #4

Merged
mechiland merged 2 commits into
mechiland:mainfrom
zo-ly:feat/pr-commit-prev-next
Oct 19, 2026
Merged

mechiland merged 2 commits into
mechiland:mainfrom
zo-ly:feat/pr-commit-prev-next

Conversation

@zo-ly

@zo-ly zo-ly commented Oct 16, 2026 •

Copy link
Copy Markdown

What

When a pull request's Files changed tab shows a single commit (/pulls/N/commits/<sha>), github.com puts the commit's message box above the diff: title, body, a Prev / Next ButtonGroup to step through the PR's commits, Browse files, and an author row with the short SHA. Gitea only shows a "Showing only changes of commit X – Show all commits" banner, so you have to go back to the commit dropdown for every step and you can't see the commit message.

This PR replaces that banner with the github.com commit box (github-* themes only):

  • Title and body are rendered like on Gitea's own commit page (issue references, emoji, links). The title always shows in full and wraps.
  • A body longer than 10 lines (as laid out, so wrapping on narrow screens counts) is folded to its first 8 lines with a fade and a Show more / Show less toggle. Squash-merge changelogs of a hundred lines then don't push Prev / Next and the diff several screens down. The full text stays in the page, so find-in-page and copy still work.
  • Prev = the next older commit of the PR, Next = the next newer one, as on github.com. The first commit's Prev and the last commit's Next are disabled. Links keep the current style / whitespace / show-outdated parameters, as Gitea's commit selector does.
  • Browse files opens the tree at that commit. The author row shows the author, the committer when different, the time, and commit <sha> with a copy button.
  • On the PR's Commits tab, the commit title now opens the same in-PR view as the SHA. Gitea links the title to the repository's /commit/<sha> page, which is outside the PR and has no Prev / Next. github.com opens the PR view from both. The repository commit list is unchanged.
  • Labels use Gitea's existing locale keys, so they are translated. In English, Gitea's "Previous" and "Browse Source" read github.com's "Prev" and "Browse files"; other languages keep their translation. Gitea has no "Show less" string, so the theme carries it for Gitea's 27 default languages (English for any other).

Screenshots (Gitea 1.27.3)

A PR with three commits, oldest to newest: C → B → A.

Middle commit (B), github-light: both buttons enabled. B's committer differs from its author.

Middle commit

Oldest commit (C), with a message body: Prev disabled, Next → B

Oldest commit

Newest commit (A): Prev → B, Next disabled

Newest commit

A 120-line squash-merge body, folded to 8 lines

Long body folded

github-dark

Dark

How

  • templates/custom/footer.tmpl: on the single-commit PR files page, walk CompareInfo.Commits (newest first, git log base..head) to find the current commit and its neighbours, render the box into a <template>, and swap it in for the banner. repo/diff/box.tmpl is not overridden because it differs between 1.27 and 28; the banner markup is identical in both. On 28.x the author row uses its repo.diff.authored_committed_at / committed_at sentence; 1.27.x does not have those keys, so it uses the commit page's "committed by" layout.
  • templates/repo/commits_list.tmpl: when PageIsPullCommits and a github-* theme is active, the title link uses the same /pulls/N/commits/<sha> base as the SHA link.
  • src/code/diff.css: the box styles (Primer tokens only). The buttons reuse the existing ButtonGroup and Button styles.

Testing

  • npm run lint and npm run build pass.
  • Tested on Gitea 1.27.3, 28.1.0 and 28.2.0 (28.2.0 upgraded from the 28.1.0 data) with the packaged theme, in github-light and github-dark. On each of the three commits the buttons point to the expected neighbours and the end buttons are disabled. Clicking a commit title on the Commits tab opens the in-PR view. With gitea-light and on the repository commit list the links are unchanged. No page errors.
  • Folding, at 1280px and 390px: a 9-line body stays open on desktop; a 13-line and a 120-line body fold to 8 lines; Show more / Show less toggle, and collapsing after scrolling down brings the box back into view. Labels checked in English, Chinese, German and Japanese.

🤖 Generated with Claude Code

zhaoliangyu and others added 2 commits October 16, 2026 12:47
When a PR's Files changed tab shows one commit, github.com puts the
commit's message box above the diff: title, body, a Prev / Next
ButtonGroup to step through the PR's commits, Browse files, and an
author row with the short SHA. Gitea only shows the "showing only
changes of commit X" banner. The custom footer renders the box from
CompareInfo.Commits and replaces that banner (no box.tmpl override,
which differs between 1.27 and 28). github-* themes only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a PR's Commits tab Gitea links the SHA to /pulls/N/commits/<sha> but
the title to the repository's /commit/<sha> page, which is outside the PR
(no Prev / Next). github.com opens the PR commit view from both. github-*
themes only; the repository commit list is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mechiland

Copy link
Copy Markdown
Owner

@zo-ly Thanks for your contribution!

can you also make sure your PR work with v28.1.0 as well?

@zo-ly

zo-ly commented Oct 19, 2026

Copy link
Copy Markdown
Author

Tested on 28.1.0 and 28.2.0, works the same as on 1.27.3.

28.2.0

@mechiland
mechiland merged commit 83c67b1 into mechiland:main Oct 19, 2026
1 check passed
@zo-ly
zo-ly deleted the feat/pr-commit-prev-next branch October 19, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants