Skip to content

Search backend: handle `repo:contains` predicates during repo resolution

Created by: camdencheek

This updates our repo resolution to handle repo:contains.file(x), repo:contains.content(y), repo:contains(file:x content:y), and repohasfile:x.

Comments inline, but the summary is:

  • RepoOptions contains everything we need to know about what repos to search
  • The logic in repo_has_file.go has been moved into the repo resolution step
  • Every combination of file and content filters is represented by the RepoHasFileContentArgs struct, which has optional fields
  • This works efficiently, and we can now reasonably do AND/OR queries with repo:contains...

Fixes https://github.com/sourcegraph/sourcegraph/issues/23566 Fixes https://github.com/sourcegraph/sourcegraph/issues/20337 Replaces https://github.com/sourcegraph/sourcegraph/pull/37637 Fixes https://github.com/sourcegraph/sourcegraph/issues/26340 Fixes https://github.com/sourcegraph/sourcegraph/issues/19688

I plan to wait to merge this until after the release cut. It's a somewhat large change, and I'd prefer to give it a release cycle in the wild. Release cut has happened. Will merge when approved.

Don't believe the lines added. It's mostly a generated mock and associated tests. This actually removes a couple hundred lines of non-generated code.

Test plan

Solid backend integration tests, existing unit tests, and added some heavily-mocked tests that hit the partitioning logic a bit. I've done quite a bit of manual edge-case testing as well.

Merge request reports

Loading