From 1991eaf8e692117dfa15d158d317e5123e53e4af Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Fri, 3 May 2024 10:43:29 +0200 Subject: [PATCH] gitindex: update remote.origin.url if clone already exists This is so that when authentication details change we correctly update the CloneURL for repositories managed by our mirror commands. --- gitindex/clone.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitindex/clone.go b/gitindex/clone.go index 2399e29fa..8bee54de0 100644 --- a/gitindex/clone.go +++ b/gitindex/clone.go @@ -18,6 +18,7 @@ import ( "bytes" "fmt" "log" + "maps" "os" "os/exec" "path/filepath" @@ -60,7 +61,9 @@ func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (stri repoDest := filepath.Join(parent, filepath.Base(name)+".git") if _, err := os.Lstat(repoDest); err == nil { - // Repository exists, ensure settings are in sync + // Repository exists, ensure settings are in sync including the clone URL + settings := maps.Clone(settings) + settings["remote.origin.url"] = cloneURL if err := updateZoektGitConfig(repoDest, settings); err != nil { return "", fmt.Errorf("failed to update repository settings: %w", err) }