Skip to content

zoekt-indexserver: Per-Entry Branch Config#1011

Open
dharesign wants to merge 1 commit intosourcegraph:mainfrom
dharesign:indexserver-branch-support
Open

zoekt-indexserver: Per-Entry Branch Config#1011
dharesign wants to merge 1 commit intosourcegraph:mainfrom
dharesign:indexserver-branch-support

Conversation

@dharesign
Copy link
Contributor

Allow specifying which branches to index per config entry via the Branches field (comma-separated, e.g. "main,release-*", default HEAD) and BranchPrefix (e.g. "refs/tags/" to index tags instead of branches).

These values are persisted as zoekt.branches-to-index and zoekt.branch-prefix in each repo's git config by the mirror commands, then read at index time and passed to zoekt-git-index as -branches and -prefix flags.

Fixes #432.

Allow specifying which branches to index per config entry via the
Branches field (comma-separated, e.g. "main,release-*", default HEAD)
and BranchPrefix (e.g. "refs/tags/" to index tags instead of branches).

These values are persisted as zoekt.branches-to-index and
zoekt.branch-prefix in each repo's git config by the mirror commands,
then read at index time and passed to zoekt-git-index as -branches and
-prefix flags.

Fixes sourcegraph#432.
Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes, but not sure if my comments are feasible.

Not the biggest fan of needing to update so many mirror commands for this, but currently this is the most obvious way to do this. I don't think we have a nice way to map indexserver config <-> cloned repo.

Maybe a more general field getting into the zoekt config for just zoekt-indexserver to read would make this code a bit cleaner / easier to add future features like this to zoekt-indexserver?

Comment on lines +167 to +179
// Read zoekt.branches-to-index from the repo's git config. If set, pass
// it to zoekt-git-index as -branches along with -allow_missing_branches.
// The value is a comma-separated list of branch names (default: HEAD).
if branchOut, err := exec.Command("git", "--git-dir", dir, "config", "zoekt.branches-to-index").Output(); err == nil {
if branches := strings.TrimSpace(string(branchOut)); branches != "" {
args = append(args, "-branches", branches, "-allow_missing_branches")
}
}
if prefixOut, err := exec.Command("git", "--git-dir", dir, "config", "zoekt.branch-prefix").Output(); err == nil {
if prefix := strings.TrimSpace(string(prefixOut)); prefix != "" {
args = append(args, "-prefix", prefix)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like it violates a layer we had before. Only zoekt-git-index would read the git config, not indexserver. Would it be possible to instead read these values in in the git indexer, and if they are set override branches-to-index or branch-prefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zoekt-indexserver: Support Per-Repository Branch Selection

2 participants