From deee448eca2479f95495726663b1d5cfc5005e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nemanja=20Zbilji=C4=87?= Date: Mon, 1 Jan 2024 10:54:45 +0100 Subject: [PATCH] feat: limit max number of retry attempts --- cmd/common.go | 2 ++ cmd/git.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/cmd/common.go b/cmd/common.go index faea83b..6ba84bb 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -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 ) diff --git a/cmd/git.go b/cmd/git.go index e381f2e..58cc375 100644 --- a/cmd/git.go +++ b/cmd/git.go @@ -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)