Skip to content

search: search indexed if @commit is at HEAD

Administrator requested to merge rvt/head-commit-index-v2 into master

Created by: rvantonder

Addresses #9022. I'm putting this up early so that there's enough time to check it carefully for 3.14 branch cut. Notes on the change:

  • Since we can specify repo@HEAD is valid, it makes sense to also use the index if the revision is HEAD.

  • If the commit is short and ambiguous, search will fail early with the standard alert:

Some repositories could not be searched The repository github.com/sourcegraph/sourcegraph matched by your repo: filter could not be searched because it does not contain the revision "c98f4".

This behavior is not part of the code that is tested or changed in this PR (i.e., the alert message would be the same message if we did unindexed search at an ambiguous commit). If we want to say something more informative like "Make sure the commit is unambiguous" that is something to do separately.

Implementation notes:

  • I wanted to integrate this change into the zoektIndexedRepos function, but had real trouble disentangling things. I tried, kept breaking tests, and kept finding myself thinking I'm breaking some existing assumption. So this PR duplicate some cod but with this change I can at least be very confident it:
  • (a) addresses the issue, without
  • (b) breaking some existing assumption (except what we want to change), and
  • (c) can be tested in isolation.

We can refactor later, or maybe review uncovers a better approach.

Merge request reports

Loading