Skip to content

Commit 7c5b778

Browse files
authored
gitindex: update remote.origin.url if clone already exists (#776)
This is so that when authentication details change we correctly update the CloneURL for repositories managed by our mirror commands.
1 parent 647e86c commit 7c5b778

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

gitindex/clone.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"bytes"
1919
"fmt"
2020
"log"
21+
"maps"
2122
"os"
2223
"os/exec"
2324
"path/filepath"
@@ -60,7 +61,9 @@ func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (stri
6061

6162
repoDest := filepath.Join(parent, filepath.Base(name)+".git")
6263
if _, err := os.Lstat(repoDest); err == nil {
63-
// Repository exists, ensure settings are in sync
64+
// Repository exists, ensure settings are in sync including the clone URL
65+
settings := maps.Clone(settings)
66+
settings["remote.origin.url"] = cloneURL
6467
if err := updateZoektGitConfig(repoDest, settings); err != nil {
6568
return "", fmt.Errorf("failed to update repository settings: %w", err)
6669
}

0 commit comments

Comments
 (0)