Skip to content

Commit

Permalink
Merge pull request #62 from grafana/61-retry-git-pull-on-error
Browse files Browse the repository at this point in the history
fix: retry git pull on error
  • Loading branch information
szkiba authored Sep 10, 2024
2 parents 430be3a + 55f8de1 commit 0940973
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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.

0 comments on commit 0940973

Please sign in to comment.