Skip to content

Commit e698bff

Browse files
committed
fix: git worktree switch invalidation loop
Invalidation loop of cached git worktree on every werf invocation may occur when WERF_HOME (`~/.werf`) is a symlink to another volume. Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
1 parent a2d26ec commit e698bff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/true_git/work_tree.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@ func prepareWorkTree(ctx context.Context, repoDir, workTreeCacheDir string, comm
8181
case err != nil:
8282
return "", fmt.Errorf("error accessing %q: %w", workTreeDir, err)
8383
default:
84+
resolvedWorkTreeDir, err := filepath.EvalSymlinks(workTreeDir)
85+
if err != nil {
86+
return "", fmt.Errorf("unable to eval symlinks of %q: %w", workTreeDir, err)
87+
}
88+
8489
isWorkTreeRegistered := false
8590
if workTreeList, err := GetWorkTreeList(ctx, repoDir); err != nil {
8691
return "", fmt.Errorf("unable to get worktree list for repo %s: %w", repoDir, err)
8792
} else {
8893
for _, workTreeDesc := range workTreeList {
89-
if filepath.ToSlash(workTreeDesc.Path) == filepath.ToSlash(workTreeDir) {
94+
if filepath.ToSlash(workTreeDesc.Path) == filepath.ToSlash(resolvedWorkTreeDir) {
9095
isWorkTreeRegistered = true
9196
}
9297
}

0 commit comments

Comments
 (0)