Skip to content

Commit 12a2f4a

Browse files
chore: Add ability to plumb opaque ID into a shard at index time with zoekt-git-index (#6)
1 parent 7d18962 commit 12a2f4a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

cmd/zoekt-git-index/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func run() int {
4646
deltaShardNumberFallbackThreshold := flag.Uint64("delta_threshold", 0, "upper limit on the number of preexisting shards that can exist before attempting a delta build (0 to disable fallback behavior)")
4747
languageMap := flag.String("language_map", "", "a mapping between a language and its ctags processor (a:0,b:3).")
4848
tenantID := flag.Int("tenant_id", 0, "tenant ID to use for indexed repositories")
49+
repoID := flag.Uint("repo_id", 0, "opaque ID to use for indexed repositories. Surfaces as `RepositoryID` in the REST search response.")
4950

5051
cpuProfile := flag.String("cpuprofile", "", "write cpu profile to `file`")
5152

@@ -77,6 +78,7 @@ func run() int {
7778
opts := cmd.OptionsFromFlags()
7879
opts.IsDelta = *isDelta
7980
opts.RepositoryDescription.TenantID = *tenantID
81+
opts.RepositoryDescription.ID = uint32(*repoID)
8082

8183
var branches []string
8284
if *branchesStr != "" {

gitindex/index.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ func setTemplatesFromConfig(desc *zoekt.Repository, repoDir string) error {
251251
}
252252
}
253253

254-
id, _ := strconv.ParseUint(sec.Options.Get("repoid"), 10, 32)
255-
desc.ID = uint32(id)
254+
idString := sec.Options.Get("repoid")
255+
if idString != "" {
256+
id, _ := strconv.ParseUint(idString, 10, 32)
257+
desc.ID = uint32(id)
258+
}
256259

257260
if desc.RawConfig == nil {
258261
desc.RawConfig = map[string]string{}

0 commit comments

Comments
 (0)