Skip to content

Commit 55f8de1

Browse files
committed
fix: retry git pull on error
1 parent 430be3a commit 55f8de1

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

cmd/lint.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,26 @@ func updateWorkdir(ctx context.Context, dir string, cloneURL string) error {
9494

9595
err = wtree.Pull(&git.PullOptions{Force: true})
9696
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
97-
return err
97+
if !errors.Is(err, git.ErrWorktreeNotClean) {
98+
return err
99+
}
100+
101+
slog.Debug("Retry pull", "url", cloneURL)
102+
103+
head, err := repo.Head()
104+
if err != nil {
105+
return err
106+
}
107+
108+
err = wtree.Checkout(&git.CheckoutOptions{Force: true, Branch: head.Name()})
109+
if err != nil {
110+
return err
111+
}
112+
113+
err = wtree.Pull(&git.PullOptions{Force: true})
114+
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
115+
return err
116+
}
98117
}
99118

100119
return nil

releases/v0.1.21.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
k6registry `v0.1.21` is here 🎉!
2+
3+
This is an internal maintenance release.
4+
5+
**Retry git pull on error**
6+
7+
In the git working directory, the file permissions are changed to make the cache persistent in GitHub action mode. As a consequence, the git pull operation will fail (if permissions have actually been changed).
8+
9+
To fix this, if the pull operation fails, the pull operation is repeated after a forced checkout operation.

0 commit comments

Comments
 (0)