search: don't fuzzify repo for GitHub-looking paths
Created by: rvantonder
The current globbing/wildcard syntax unconditionally fuzzifies repo paths. There are some unavoidable cases where this doesn't behave reasonably for results. The main example is, when searching for:
github.com/sourcegraph/sourcegraph auth
there are hits in the exact repo github.com/sourcegraph/sourcegraph
, but due to the order and nondeterminism that we search repositories (and return results quickly), you will see results for auth
in repos other than github.com/sourcegraph/sourcegraph
first:

So that we can go ahead with our user testing, this PR recognizes GH-like paths like github.com/foo/bar
for repos and then does not fuzzify them. This gives us behavior that is similar to what we did for rev
and what @keegancsmith mentioned in https://github.com/sourcegraph/sourcegraph/issues/12892#issuecomment-672410403. Note: I am choosing a method that has the smallest footprint of changes to get the desired result, not necessarily the most ideal. I played around with attempts that try to resolve the exact repo first, but it won't work well from a UX POV for other reasons. When search expressions are enabled, there is another route, by expressing the search as repo:^exact-attempt$ or repo:fuzzy-attempt
, but that's not possible right now and also imposes other things like ordering how expression are evaluated. I think the hardcoded github
case works fine for now for practical/testing/feedback purposes.
Obviously this means that GH-like paths that don't match an exact repo won't give results--here, a user needs to add explicit *
syntax. I think this is a totally fair compromise (we can certainly do better to propose such queries, e.g., no repo resolved).
Merge request reports
Activity
Created by: codecov[bot]
Codecov Report
Merging #13166 into main will decrease coverage by
0.00%
. The diff coverage is100.00%
.@@ Coverage Diff @@ ## main #13166 +/- ## ========================================== - Coverage 51.36% 51.35% -0.01% ========================================== Files 1486 1486 Lines 82711 82713 +2 Branches 6746 6746 ========================================== - Hits 42481 42475 -6 - Misses 36624 36630 +6 - Partials 3606 3608 +2
Flag Coverage Δ #go 52.51% <100.00%> (-0.02%)
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files Coverage Δ internal/search/query/transformer.go 93.63% <100.00%> (+0.04%)
internal/db/helpers.go 100.00% <0.00%> (ø)
internal/gosrc/stdlib.go 100.00% <0.00%> (ø)
internal/conf/platform.go 100.00% <0.00%> (ø)
internal/routevar/util.go 100.00% <0.00%> (ø)
internal/timeutil/week.go 100.00% <0.00%> (ø)
internal/vcs/git/mocks.go 100.00% <0.00%> (ø)
internal/db/query/query.go 100.00% <0.00%> (ø)
internal/highlight/mocks.go 100.00% <0.00%> (ø)
internal/routevar/regexp.go 100.00% <0.00%> (ø)
... and 733 more