Fix bug caused in previous PR

The .git to check is not the root/.git but the link/.git - tests pass
now.
This commit is contained in:
Tim Hockin 2022-01-24 10:45:11 -08:00
parent 0ce336f03c
commit 76654434f2
1 changed files with 3 additions and 3 deletions

View File

@ -987,9 +987,9 @@ func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot,
askpassCount.WithLabelValues(metricKeySuccess).Inc() askpassCount.WithLabelValues(metricKeySuccess).Inc()
} }
gitRepoPath := filepath.Join(gitRoot, ".git") currentWorktreeGit := filepath.Join(dest, ".git")
var hash string var hash string
_, err := os.Stat(gitRepoPath) _, err := os.Stat(currentWorktreeGit)
switch { switch {
case os.IsNotExist(err): case os.IsNotExist(err):
// First time. Just clone it and get the hash. // 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 return false, "", err
} }
case err != nil: 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: default:
// Not the first time. Figure out if the ref has changed. // Not the first time. Figure out if the ref has changed.
local, remote, err := getRevs(ctx, dest, branch, rev) local, remote, err := getRevs(ctx, dest, branch, rev)