Repository navigation
search: search the code of repositories - #8549
Merged
Merged
Conversation
unknwon
added a commit
that referenced
this pull request
Nov 14, 2026
unknwon
added a commit
that referenced
this pull request
Nov 14, 2026
4 tasks done
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 14, 2026 05:43
e13491f to
3ae738c
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
2 times, most recently
from
November 14, 2026 07:11
5ae8aed to
cc9b91f
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
5 times, most recently
from
November 14, 2026 18:49
6edb0a8 to
8e58e07
Compare
4 tasks done
unknwon
force-pushed
the
code-search-react-flamego
branch
3 times, most recently
from
November 14, 2026 19:40
b55a615 to
b850779
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
8 times, most recently
from
November 14, 2026 23:31
6b108a6 to
4beff3a
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 16, 2026 00:46
f4542d2 to
2ca1562
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 16, 2026 01:45
2ca1562 to
aa4c3ba
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 16, 2026 02:24
aa4c3ba to
a87fb44
Compare
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 16, 2026 03:07
a87fb44 to
670c6a3
Compare
unknwon
marked this pull request as ready for review
November 17, 2026 16:10
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
unknwon
added a commit
that referenced
this pull request
Nov 17, 2026
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 17, 2026 16:36
670c6a3 to
92ee3db
Compare
unknwon
added a commit
that referenced
this pull request
Nov 17, 2026
Search the files of a branch, a tag or a commit for lines that contain a keyword, ignoring case, with `git grep` on the tree. Nothing is indexed, so there is no extra disk use and nothing to keep up to date. A search lists at most 200 lines, 10 per file, stops after 10 seconds, and at most one search per CPU runs at a time. The search page is reached from the "Search code" button of the file browser and lists the matching lines by file, linked to the lines in the file view.
Search the default branches of all repositories the viewer can read from a new search page at /search, reached from a search box in the navbar and from the pages of organizations. Qualifiers narrow down the search like on GitHub: org: and user: for the repositories of an owner, repo: for one repository, and path: for files whose path contains a text or matches a pattern. Per-repository search takes path: too. The search box shows qualifiers as chips and suggests qualifiers, and owners and repositories for their values, while typing. Results show the lines around each match and are highlighted like the file view. The name "search" is now reserved for users and organizations.
unknwon
force-pushed
the
code-search-react-flamego
branch
from
November 17, 2026 17:07
3a6db37 to
f1e94b7
Compare
An exhaustive search lists every matching line of a file, up to 5,000 lines, and gets a minute rather than 10 seconds.
Letter case is still ignored by default. With matchCase=true, both the search of a repository and of all repositories match it, and so does the marking of matches.
Match case and Exhaustive search move from checkboxes beside the search box into a menu behind one button after it, which shows how many of them are on.
Match case and Exhaustive search move from a menu after the search button into icon toggles at the end of the search box, with a tooltip, which look pressed when on. Turning one runs the search of what is in the box.
Windows does not allow colons in paths, so the test commits a file with only a space in its name there.
3 of 4 tasks
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
Adds built-in code search with
git grep, so there is no index to build, store or keep up to date./{owner}/{repo}/search/{ref}?q=)./search?q=) and a "Search code" button on organization pages.org:anduser:for the repositories of an owner,repo:owner/namefor one repository, andpath:for files whose path contains a text or matches a*pattern. Repository search takespath:.?matchCase=true). Letter case is ignored by default.?exhaustive=true). When a search is cut short, it also offers to run an exhaustive one.Matching is literal. Binary files are skipped.
With the glass look on, results, the empty state and the timeout warning sit on glass panels, the search boxes take the field color, and the suggestions blur what is behind them like other popovers.
Limits
A search lists at most 200 matching lines and 10 per file, stops after 10 seconds, and at most one search per CPU runs at a time. An exhaustive search of a repository lists at most 5,000 matching lines with no limit per file, and stops after a minute. A search of all repositories looks at up to 1,000 of them, most recently updated first, and shows what it found so far when it runs out of time.
Behavior changes
searchis reserved for users and organizations.Screenshots
Search all repositories, scoped to an organization and a path
Suggestions for qualifiers and their values
repo:Search in a repository
Search options
Match case (
Aa) and Exhaustive search sit at the end of the search box, and look pressed when on. Turning one runs the search of what is in the box again.newRepoin the gogs source finds 11 files withNewRepoandnewRepomarked by default, and 8 files with onlynewRepowith Match case.When a search is cut short, it offers an exhaustive one. In the gogs source,
errors.Wraplists 200 lines in 28 files, and 720 lines in 85 files when exhaustive.Search buttons on the repository home page, in the file browser and on organization pages
Glass look
At 375px
Checklist
Test plan
go test ./cmd/gogs/internal/web/ ./internal/git/ ./internal/database/passes, including thegit greptests with and without matching case, and the query parser.golangci-lint run ./...reports no issues. Inweb/,tsc -b,pnpm run lint, Prettier andpnpm run buildpass.-shuffle=on, and every route has a test.TestCodeSearchsearches a public and a private repository of one user as the owner, another user and an anonymous viewer: results with one line of context, case-insensitive matching,path:with text and with*, a search at a commit before the files existed, an unknown ref (404), and an exhaustive search: a file with 15 matches lists 10 by default and withexhaustive=false, and all 15 with their context lines withexhaustive=true,path:still applies, a file with 5,001 matches lists 5,000 and is marked truncated, and a private repository stays hidden from other viewers, Match case in a repository, with an exhaustive search and across all repositories, where lines around a match that contain the keyword in another case stay context, anduser:andrepo:across all repositories. Neither search nor naming the private repository withrepo:returns its code to the other viewers. The test fails without the read check on repositories, whenpath:is ignored, and without context lines. The exhaustive tests fail when it keeps the limit per file, keeps the limit of 200 lines, has no limit, drops context lines, ignorespath:, or turns on for any value ofexhaustive. The Match case tests fail when either search ignoresmatchCase, when Git always ignores case, and when matches are marked ignoring case.-tags prodand checked in the browser: the search of all repositories withorg:andpath:chips, qualifier and repository suggestions, a repository search with apath:chip, the search buttons on the repository home page, the file browser and an organization page, the empty search page, and an exhaustive search: the toggle and the "Run an exhaustive search" link both set?exhaustive=true, andpath:internal/database errors.Wrapin the gogs source goes from 115 to 169 lines, and Match case on both search pages, alone and with an exhaustive search. A toggle searches for what is typed in the box even before it is submitted, works with Space from the keyboard, and does not open the suggestions. Checked in light, dark, light glass and dark glass at 1280px and at 375px, including the navbar search box and its suggestions, and the timeout warning (by marking a response as timed out in the browser). Nothing scrolls sideways at 375px, and long code lines scroll inside their result.