I recently heard about Sourcegraph code search from a news story, and while that’s not a great introduction it does seem like a useful tool.
Github search is great for searching one repo, or searching all repos in an organization, but what if you want to search all ROS repos no matter what org they’re in? Sourcegraph lets you do that. I created some SearchContext
s on the public instance that let you search almost all released ROS source code.
context:@sloretz/ROS-Noetic
context:@sloretz/ROS-Humble
context:@sloretz/ROS-Iron
context:@sloretz/ROS-Rolling
Examples:
- Find
call_async
in Python code in ROS Humble:context:@sloretz/ROS-Humble lang:python call_async
- Find XML files with a
<launch>
tag in ROS Rolling:context:@sloretz/ROS-Rolling lang:xml "<launch>"
- Find repositories in ROS Noetic that have been archived:
context:@sloretz/ROS-Noetic archived:only
Query syntax reference: Search query syntax - Sourcegraph docs
Limitations
These search the repos at the branch given in the source
entry of each repository on rosdistro. Not every repository has a source entry, and those that do sometimes have the wrong branch. For example, a maintainer might release a package in ROS Iron from their main
branch, but later create an iron
branch and forget to update it. For repos that don’t have a source entry I made the SearchContext
s search the latest release branch in the release repository for each released package.
A lot of repositories are not indexed on the public Sourcegraph instance, though the core ones mostly are. I don’t know how frequently these are reindexed.
- ROS Noetic: 516 out of 754 repos are indexed
- ROS Humble: 347 out of 519 repos are indexed
- ROS Iron: 318 out of 446 repos are indexed
- ROS Rolling: 309 out of 439 repos are indexed
These SearchContext
s will need to be periodically updated as repos are added and updated in rosdistro. They reflect the repos and branches as of this morning, or of whenever I get around to updating them in the future.
I also have only been playing with these contexts today, so let me know if you find issues. I’ll do my best to fix them.