Skip to content

Commit

Permalink
feat: limit max number of retry attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
zbiljic committed Jan 1, 2024
1 parent 49820fe commit deee448
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ const (
defaultRetryWaitMin = time.Second
defaultRetryWaitMax = 10 * time.Second
defaultRetryMaxElapsedTime = time.Minute
defaultRetryMaxAttempts = 100
)

var (
retryWaitMin = defaultRetryWaitMin
retryWaitMax = defaultRetryWaitMax
retryMaxElapsedTime = defaultRetryMaxElapsedTime
retryMaxAttempts = defaultRetryMaxAttempts
)
4 changes: 4 additions & 0 deletions cmd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ func gitCheckAndPull(ctx context.Context, repoPath string) error {
prefixPrinter.Printfln("attempt: %d", attempt)
}

if attempt > retryMaxAttempts {
break
}

// attempt the pull
err = gitPull(ctx, repoPath)

Expand Down

0 comments on commit deee448

Please sign in to comment.