zoekt-indexserver: Per-Entry Branch Config#1011
zoekt-indexserver: Per-Entry Branch Config#1011dharesign wants to merge 1 commit intosourcegraph:mainfrom
Conversation
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.
keegancsmith
left a comment
There was a problem hiding this comment.
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?
| // 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) | ||
| } | ||
| } |
There was a problem hiding this comment.
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
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.