Skip to content

web: search repository branches and add GitHub-style branch tabs - #8590

Merged
unknwon merged 1 commit into
mainfrom
branch-search-react-flamego
Nov 16, 2026
Merged

unknwon merged 1 commit into
mainfrom
branch-search-react-flamego

Conversation

@unknwon

@unknwon unknwon commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Adds GitHub-style tabs and search to the repository branches page. The page now has five views, each with its own URL: Overview (/{owner}/{repo}/branches), Yours (/branches/yours), Active (/branches/active), Stale (/branches/stale) and All (/branches/all). A "Search branches…" field narrows any view by branch name, and the URL keeps the search as ?query=, so links are shareable and Back works.

  • One Git call for all branches. GET /api/web/{owner}/{repo}/branches reads every branch with a single git for-each-ref refs/heads --sort=-committerdate, which returns the name, commit, committer date, name and email, newest first. Before, it ran one git cat-file per branch. The new helper is git.Repository.BranchesByCommitterDate.
  • Views, search and paging on the server. The endpoint takes view=overview|yours|active|stale|all (default overview, anything else is 400), query= and page=.
    • query matches branch names by case-insensitive substring.
    • The views other than the overview return 20 branches a page with page and hasNext. The UI shows Previous and Next.
    • Active means updated in the last 30 days, and stale means not updated for 90 days, as before. Yours, Active and Stale leave out the default branch, and All includes it.
    • The overview keeps its default, active and stale groups, and adds "Your branches" for signed-in viewers. Each group shows up to 5 branches, with "View more" linking to its view when there are more.
    • Response: { defaultBranch, view, sections: [{ kind, branches, hasMore }], branches, page, hasNext, viewerCanWrite, allowsPulls, viewerCanChangeDefault }. sections is only filled for the overview and branches only for the other views.
  • Yours is the branches whose last commit was committed with one of the viewer's activated email addresses, including the primary one. The tab and the "Your branches" group are hidden for signed-out viewers, and a signed-out view=yours request returns an empty list (200).
  • Search updates the URL 300ms after typing stops, and the route loader refetches. Refining a search replaces the history entry, so Back leaves the search instead of replaying every keystroke. Searching from Overview moves to All, as GitHub does. When nothing matches, the page says No branches match "…".
  • Narrow screens: below sm the search field moves under the tabs, and the tab row scrolls sideways on its own, with the current tab scrolled into view. The page stays 375px wide.
  • Only the current tab is marked aria-current="page" now. Before, the Overview link was also marked on /branches/all, because the router matched it as a parent path.
  • web/DESIGN.md describes the scrolling view switcher and the search-as-you-type field.

Behavior changes

  • The overview shows up to 5 branches per group with "View more", instead of every active and stale branch.
  • All branches is paged, 20 a page, instead of listing every branch at once.
  • The groups are computed on the server when the page loads, not in the browser.

Screenshots

Overview as alice, with Your branches

Overview as alice, with Your branches

Yours as alice: matches her primary and secondary activated emails, not an unverified one

Yours as alice

Yours as bob

Yours as bob

Active

Active

Stale

Stale

All, page 2

All, page 2

Searching "feat" from the overview moves to All

Searching feat from the overview moves to All

A search with no matches

A search with no matches

Signed out: no Yours tab or Your branches group

Signed out: no Yours tab or Your branches group

Active in dark mode

Active in dark mode

Overview at 375px
Overview at 375px
Search at 375px, All scrolled into view
Search at 375px
Stale at 375px
Stale at 375px

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code and provided the test plan below.
  • I have added an entry to CHANGELOG.

Test plan

  1. go test ./internal/git/ ./cmd/gogs/internal/web/ ./internal/route/... passes. TestRepository_BranchesByCommitterDate covers the order, the committer fields, a time zone offset and feature/search, a branch with a slash. TestBranchesFilter_SelectBranches covers mixed-case search, the 30 and 90 day boundaries, Yours with another user's email, signed out, and 20 versus 21 branches.
  2. go vet ./cmd/... ./internal/... and golangci-lint run ./... report 0 issues. In web/, pnpm run build, pnpm exec tsc -b and pnpm run lint pass.
  3. Ran a -tags prod build with SQLite. Pushed 25 branches to alice/alpha with committer dates from 1 to 500 days ago and various committers. Gave alice a secondary activated email and an unverified one, and committed branches with each, and with bob's email.
  4. API: the overview has default, active and stale groups signed out, and adds yours for alice. view=all returns 20 with hasNext: true, and page 2 returns the last 6 with hasNext: false. query=FEAT matches feature/… and FEATURE/…. view=bogus returns 400. Signed out, view=yours returns an empty list.
  5. Yours: alice sees the branches committed with her primary and secondary emails, not the one with her unverified email. bob sees only his four branches. Signed out, the tab is hidden.
  6. Search: typing "fea" on the overview left the URL unchanged until typing paused, then moved to /branches/all?query=fea with the field still focused. Typing "t" replaced it with ?query=feat, and Back returned to the overview with an empty field. In Active, "nothing-here" showed the empty state, and Back cleared it.
  7. Paging: Next on All went to ?page=2, and Back returned to page 1.
  8. Narrow screens and dark mode: at 375px, document.documentElement.scrollWidth is 375 on the overview, Yours and a search. The tab row scrolls on its own, and on All and Stale the current tab starts in view. Checked dark mode at 1280.

unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the branch-search-react-flamego branch from 32d8b74 to 11cc1b5 Compare November 16, 2026 03:43
@unknwon
unknwon force-pushed the branch-search-react-flamego branch from 11cc1b5 to f81709a Compare November 16, 2026 03:51
@unknwon
unknwon merged commit 5973ded into main Nov 16, 2026
12 checks passed
@unknwon
unknwon deleted the branch-search-react-flamego branch November 16, 2026 04:00
@unknwon unknwon mentioned this pull request Nov 16, 2026
2 of 4 tasks
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.

1 participant