Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retry git pull on error #62

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,26 @@ func updateWorkdir(ctx context.Context, dir string, cloneURL string) error {

err = wtree.Pull(&git.PullOptions{Force: true})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return err
if !errors.Is(err, git.ErrWorktreeNotClean) {
return err
}

slog.Debug("Retry pull", "url", cloneURL)

head, err := repo.Head()
if err != nil {
return err
}

err = wtree.Checkout(&git.CheckoutOptions{Force: true, Branch: head.Name()})
if err != nil {
return err
}

err = wtree.Pull(&git.PullOptions{Force: true})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return err
}
}

return nil
Expand Down
9 changes: 9 additions & 0 deletions releases/v0.1.21.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
k6registry `v0.1.21` is here 🎉!

This is an internal maintenance release.

**Retry git pull on error**

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).

To fix this, if the pull operation fails, the pull operation is repeated after a forced checkout operation.
Loading