Skip to content

Commit

Permalink
Merge pull request #4 from Q42Philips/bugfix/retry-on-missing-tag
Browse files Browse the repository at this point in the history
Retry on missing tag
  • Loading branch information
EDeijl authored May 20, 2022
2 parents 3f24990 + 442ae2b commit 97e223e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
log.Printf("Waiting for tags (%q) to include synced commit", Global.WaitForTags.String())
err = gitlogic.WaitForTags(context.Background(), Global, result.Commit, result.Repository)
if err != nil {
log.Printf("Error waiting for tags: %s", err)
os.Exit(1)
} else {
os.Exit(0)
Expand Down
6 changes: 4 additions & 2 deletions pkg/gitlogic/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ func WaitForTags(ctx context.Context, c Config, commit plumbing.Hash, repo *git.
})
if err != nil && err != git.NoErrAlreadyUpToDate {
// If the tag is removed from the remote, we should remove it too
var errNoMatching = &git.NoMatchingRefSpecError{}
var errNoMatching = git.NoMatchingRefSpecError{}
if isRemoteMissing := errors.As(err, &errNoMatching); isRemoteMissing {
return errors.Wrap(err, "failed to wait because one of the tags disappeared")
log.Printf("failed to fetch tag: %s", err.Error())
time.Sleep(2 * time.Second)
continue
}
return errors.Wrap(err, "fetching tag refs")
}
Expand Down

0 comments on commit 97e223e

Please sign in to comment.