Skip to content

Commit 00eb6a8

Browse files
committed
handle partial directory removal during repo cloning in gitutil.go
1 parent 5dc5b09 commit 00eb6a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/skaffold/git/gitutil.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ func syncRepo(ctx context.Context, g Config, opts config.SkaffoldOptions) (strin
125125
return "", SyncDisabledErr(g, repoCacheDir)
126126
}
127127
if _, err := r.Run(ctx, "clone", g.RepoCloneURI, fmt.Sprintf("./%s", hash), "--branch", ref, "--depth", "1"); err != nil {
128+
// Remove partially created directory before attempting full clone
129+
if rmErr := os.RemoveAll(repoCacheDir); rmErr != nil {
130+
return "", fmt.Errorf("failed to remove partially created repo directory: %w", rmErr)
131+
}
132+
128133
if _, err := r.Run(ctx, "clone", g.RepoCloneURI, fmt.Sprintf("./%s", hash)); err != nil {
129134
return "", fmt.Errorf("failed to clone repo: %w", err)
130135
}

0 commit comments

Comments
 (0)