Skip to content

web: make the code browser look like GitHub's - #8630

Merged
unknwon merged 3 commits into
mainfrom
code-browser-github-look
Nov 16, 2026
Merged

unknwon merged 3 commits into
mainfrom
code-browser-github-look

Conversation

@unknwon

@unknwon unknwon commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Stacked on #8536.

The code browser now looks and works like GitHub's, using only data Gogs already has or that #8551 adds:

  • About column on the repository home: the description, the website, links to the README and to the license, contributing guide and security policy in the root directory, the stars, watchers and forks, and the number of releases. On phones, the description, website and counts show above the file list instead.
  • Branch and tag counts next to the branch picker.
  • Go to file finds a file of the current commit as you type, ranking a file name that starts with the query first. t focuses it, as on GitHub. Matching letters in order only counts when nothing contains the query as typed.
  • Add file menu holds "New file" and "Upload file".
  • Latest commit bar is one line: the avatars and names of the author and co-authors, the message, then "SHA · time" and the commit count. A commit with Co-authored-by trailers shows "alice and carol", or "alice and 3 others", which lists everyone on a click. The commits page shows co-authors the same way.
  • Single-child folders show as one row, e.g., cmd/gogs, with filled folder icons. This applies to directories with at most 100 subdirectories, since each level costs a tree read.
  • File tree sidebar on files and folders below the root, on wide screens, with the branch picker and Go to file above it. It opens the path shown, follows the back button, and remembers whether it is open.
  • Breadcrumb row has a copy path button and a "..." menu with Permalink, Copy permalink and Go to line.
  • File toolbar shows "N lines (M loc) · size", then Raw, Copy and Download as one group, then edit and delete.

New endpoint GET /api/web/{owner}/{repo}/paths[/{ref}] lists every file path of a ref, at most 50,000, from #8551 with git.Repository.TreePaths. Commit list items now have coAuthors.

Link to the issue: n/a

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 or have provided the test plan. (if applicable)
  • I have added an entry to CHANGELOG. (if applicable)

Screenshots

Repository home: About column, counts, Go to file, Add file, co-authors and flattened folders

Repository home with the About column and a one-line commit bar showing alice and Carol

Go to file

Go to file listing cmd/gogs/main.go first for the query main.go

Add file menu

Add file menu with New file and Upload file

More than two authors

alice and 3 others opened to list alice, Bob, Carol and Dana Outside

Commits page with co-authors

Commits page whose first commit shows alice and 3 others

File with the tree sidebar and the file toolbar

main.go open with the file tree sidebar and the toolbar showing 63 lines (57 loc)

"..." menu and Go to line

The more file actions menu with Permalink, Copy permalink and Go to line

Go to line dialog with 40 entered

Tree hidden

main.go with the tree hidden and the show file tree button before the branch picker

Folder page with the folder open in the tree

internal/git selected and open in the tree beside its file list

Dark mode

Repository home in dark mode

File page with the tree in dark mode

375px

Repository home at 375px with the description and counts above the file list File page at 375px without the tree

Test plan

  1. Push a commit with Co-authored-by: Carol <[email protected]> and open the repository home. The commit bar shows both avatars and "alice and Carol", and About lists the README, license and security policy that exist in the root.
  2. Press t and type main.go. Only paths that contain it are listed, file names first. Enter opens the first one.
  3. Open a file. The tree opens to it with the file selected. Pick another file in the tree, then press back. The page and the selection go back.
  4. Open "...", pick Go to line, and enter 40. The URL gets #L40 and line 40 is selected and scrolled into view.
  5. Hide the tree and open a folder. The tree stays hidden until shown again. When shown on a folder page, the folder is open in the tree.
  6. Repeat in dark mode and at 375px wide. Nothing scrolls sideways and the tree is hidden on phones.

go test ./internal/git/ ./cmd/gogs/internal/web/ (with TestCoAuthorsOf and TestRepository_TreePaths), golangci-lint, tsc, eslint, prettier and the web build pass.

AI usage

Written with Amp.

unknwon added a commit that referenced this pull request Nov 16, 2026
The repository home gets an About column, branch and tag counts, "Go to
file", an "Add file" menu, a one-line latest commit bar with co-authors,
and flattened single-child folders. Files and folders below the root get a
file tree sidebar, a copy path button, a "..." menu with the permalink and
"Go to line", and a file toolbar with lines of code, Raw, Copy and
Download.

The paths endpoint and git.Repository.TreePaths come from #8551.
@unknwon
unknwon force-pushed the code-browser-github-look branch from 815aa89 to 229c1d5 Compare November 16, 2026 17:42
@unknwon
unknwon merged commit 1ef0058 into main Nov 16, 2026
12 checks passed
@unknwon
unknwon deleted the code-browser-github-look branch November 16, 2026 19:30
unknwon added a commit that referenced this pull request Nov 16, 2026
#8630 merged while #8529 was open, so main does not build.
unknwon added a commit that referenced this pull request Nov 16, 2026
The code browser handlers from #8630 still called the clog package that
#8529 removed, so main did not build.
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