Extension request: search a repository and its dependencies
Created by: sqs
After https://github.com/sourcegraph/sourcegraph-extension-api/pull/95 is merged, extensions can define custom search query keywords. As a developer who is trying to understand a codebase, it would help me to be able to perform a search across a given repo and all of its dependencies (i.e., the universe of code relevant to it).
For example, I would like to be able to perform the following searches on Sourcegraph:
-
repo+deps:github.com/sourcegraph/sourcegraph ApplyEdits
(to find thejsonx.ApplyEdits
func -
repo+deps:github.com/sourcegraph/sourcegraph-extension-api combineLatest
to find the definition ofcombineLatest
in RxJS's TypeScript sources
One tricky thing is how to support multiple languages. I think the same keyword should be used (repo+deps:
), not language-specific keywords like repo+go-deps:
. But the logic for enumerating dependencies for code in a particular language is quite complex in general, and it can be slow. An impl for just a single language would be a good start.
This seems especially useful to use with the src
CLI's search command, to use on the terminal.
This is not very useful for repos that vendor all of their dependencies. Fewer projects are doing so these days, esp. with tools like yarn/npm/go modules making it safe and reproducible even if you don't vendor.
Example use case:
Trying to debug a problem in the rust language server, but the root cause seems to be in a dependency of it (the jsonrpc parser). Was doing lots of searches with the stuff in the trace log. We would've found this problem much faster if we had a way to search a repo and its dependencies. (I manually was looking for interesting packages in the Cargo.lock when I couldn't find hits for certain error codes)