From 76654434f240e3f422e1bfcd3f394bfee020a9b3 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Mon, 24 Jan 2022 10:45:11 -0800 Subject: [PATCH] Fix bug caused in previous PR The .git to check is not the root/.git but the link/.git - tests pass now. --- cmd/git-sync/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 55577ce11..e52148698 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -987,9 +987,9 @@ func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot, askpassCount.WithLabelValues(metricKeySuccess).Inc() } - gitRepoPath := filepath.Join(gitRoot, ".git") + currentWorktreeGit := filepath.Join(dest, ".git") var hash string - _, err := os.Stat(gitRepoPath) + _, err := os.Stat(currentWorktreeGit) switch { case os.IsNotExist(err): // First time. Just clone it and get the hash. @@ -1002,7 +1002,7 @@ func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot, return false, "", err } case err != nil: - return false, "", fmt.Errorf("error checking if repo exists %q: %v", gitRepoPath, err) + return false, "", fmt.Errorf("error checking if a worktree exists %q: %v", currentWorktreeGit, err) default: // Not the first time. Figure out if the ref has changed. local, remote, err := getRevs(ctx, dest, branch, rev)