This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Cody context: fix an issue with anchoring repo names#63585
Merged
Conversation
jtibshirani
approved these changes
Jul 2, 2024
jtibshirani
left a comment
Contributor
There was a problem hiding this comment.
Wow, I'm surprised we didn't catch this until now. I guess it really shows the power of Cody Web for dogfooding. And that we haven't worked on multi-repo context enough.
| regexEscapedRepoNames[i] = fmt.Sprintf("^%s$", regexp.QuoteMeta(string(repo.Name))) | ||
| } | ||
|
|
||
| keywordQuery := fmt.Sprintf(`repo:^%s$ %s %s`, query.UnionRegExps(regexEscapedRepoNames), getKeywordContextExcludeFilePathsQuery(), args.Query) |
Contributor
There was a problem hiding this comment.
Although it's a simple fix, it'd be great to pull out a method like createKeywordQuery and add a couple cases in context_test.go!
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes SRCH-658
This fixes an issue with anchoring repos in the keyword search query used for cody context.
Previously, we would use a
repo:pattern likerepo:^(?:a)|(?:b)$. However, the union operator binds loosely, so this is interpreted as matching(^a)|(b$)rather than^(a|b)$.This fixes the pattern so we add the anchors to every repo name. Alternatively, we could modify the behavior of
UnionRegExp, but that seemed riskier.Test plan
Quick manual test that context for
github.com/sourcegraph/docsdoes not return any files fromgithub.com/sourcegraph/docsiteChangelog