fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Update the zoekt config for a repo every mirror_interval (#600)

+26
+26
gitindex/clone.go
··· 16 16 17 17 import ( 18 18 "bytes" 19 + "fmt" 19 20 "log" 20 21 "os" 21 22 "os/exec" ··· 26 27 "github.com/go-git/go-git/v5/config" 27 28 ) 28 29 30 + // Updates the zoekt.* git config options after a repo is cloned. 31 + // Once a repo is cloned, we can no longer use the --config flag to update all 32 + // of it's zoekt.* settings at once. `git config` is limited to one option at once. 33 + func updateZoektGitConfig(repoDest string, settings map[string]string) error { 34 + var keys []string 35 + for k := range settings { 36 + keys = append(keys, k) 37 + } 38 + sort.Strings(keys) 39 + 40 + for _, k := range keys { 41 + if settings[k] != "" { 42 + if err := exec.Command("git", "-C", repoDest, "config", k, settings[k]).Run(); err != nil { 43 + return err 44 + } 45 + } 46 + } 47 + 48 + return nil 49 + } 50 + 29 51 // CloneRepo clones one repository, adding the given config 30 52 // settings. It returns the bare repo directory. The `name` argument 31 53 // determines where the repo is stored relative to `destDir`. Returns ··· 38 60 39 61 repoDest := filepath.Join(parent, filepath.Base(name)+".git") 40 62 if _, err := os.Lstat(repoDest); err == nil { 63 + // Repository exists, ensure settings are in sync 64 + if err := updateZoektGitConfig(repoDest, settings); err != nil { 65 + return "", fmt.Errorf("failed to update repository settings: %w", err) 66 + } 41 67 return "", nil 42 68 } 43 69