By default, only the default branch of a repository is indexed and can be searched. Sourcebot can be configured to index additional branches (or tags) enabling multi-branch search. This is useful for scenarios such as:

  • Searching across different releases
  • Searching through feature branches during development
  • Tracking changes across multiple maintenance branches simultaneously

Configuration

Multi-branch indexing is currently limited to 64 branches and tags. If this limitation impacts your use-case, please open a discussion.

Multi-branch indexing is configured on in the connection using the revisions.branches and revisions.tags arrays. Glob patterns are supported. For example:

{
    "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
    "connections": {
        "my-connection": {
            "type": "github",
            // For each of the repositories defined in this connection...
            "repos": [
                "org/repo1",
                "org/repo2"
            ],
            // ... index the default branch, as well as...
            "revisions": {
                // These branches (if they exist):
                "branches": [
                    // Exact matches
                    "dev",
                    "staging",

                    // Glob patterns
                    "feature/*" // Matches: feature/auth, feature/ui, etc.
                ],
                
                // These tags (if they exist):
                "tags": [
                    // Exact matches
                    "v4.0.0-dev",
                    
                    // Glob patterns
                    "v3.*.*", // Matches: v3.0.0, v3.0.1, etc.
                    "rc-*"    // Matches: rc-1, rc-2, etc.
                ]
            }
        }
    }
}

For each repo defined in the connection, any branches or tags matching the patterns in branches and tags array will be indexed.

Search syntax

To search branches other than the default, the rev: prefix can be used followed by the branch (or tag) name:

ExampleExplanation
rev:feature/foo repo:A useEffectSearch for /useEffect/ on branch feature/foo in repo A
rev:feature/foo useEffect Search for /useEffect/ on branch feature/foo across all repos
rev:feature/ useEffectSearch for /useEffect/ on branches that contain feature/ across all repos
rev:feature/a rev:feature/b fooSearch for /foo/ on branches feature/a and feature/b
rev:feature/ -rev:feature/a fooSearch for /foo/ on branches that contain feature/ except for feature/a across all repos

To search across all branches, rev:*:

ExampleExplanation
rev:* repo:A "error message"Search for /error message/ across all branches in repo A
rev:* "error message"Search for /error message/ across all branches and all repos

Additional info:

  • refs/heads/ or refs/tags/ can be included to fully qualify a branch or a tag, respectively. E.g., rev:refs/heads/foo will search the branch foo, while rev:refs/tags/foo will search the tag foo.
  • rev: does not support regular expressions or glob patterns. It uses a simple contains call between the branch name and the pattern. See here.

Platform support

PlatformMulti-branch indexing support
GitHub
GitLab
Bitbucket Cloud
Bitbucket Data Center
Gitea
Gerrit