sourcegraph / cody

AI that knows your entire codebase
https://cody.dev
Apache License 2.0
2.24k stars 213 forks source link

mentions: remote file search regex escapes and anchors inputs #4638

Closed keegancsmith closed 1 week ago

keegancsmith commented 1 week ago

Our search language takes regular expressions as input so we need to escape the user input. Additionally for repository we need to add anchors otherwise we will match all repos that contain another repo name. For example at Sourcegraph we have the deploy-sourcegraph repo as well as many example of deploy-sourcegraph-${target} repos.

Test Plan: remote file search on deploy-sourcegraph only returned filenames for deploy-sourcegraph when signed into s2. Additionally adding "." in the filename selection only selected "." and didn't match any char.

See before and after screenshots

Before

image image

After

image image

Fixes https://linear.app/sourcegraph/issue/CODY-2265/regex-escape-reponame-and-filepath-for-remote-files-provider