Merge pull request #133 from jacksontj/failure
Add option to allow for unlimited failures
This commit is contained in:
commit
772c3b3078
|
|
@ -58,7 +58,7 @@ var flSyncTimeout = flag.Int("timeout", envInt("GIT_SYNC_TIMEOUT", 120),
|
|||
var flOneTime = flag.Bool("one-time", envBool("GIT_SYNC_ONE_TIME", false),
|
||||
"exit after the initial checkout")
|
||||
var flMaxSyncFailures = flag.Int("max-sync-failures", envInt("GIT_SYNC_MAX_SYNC_FAILURES", 0),
|
||||
"the number of consecutive failures allowed before aborting (the first pull must succeed)")
|
||||
"the number of consecutive failures allowed before aborting (the first pull must succeed, -1 disables aborting for any number of failures after the initial sync)")
|
||||
var flChmod = flag.Int("change-permissions", envInt("GIT_SYNC_PERMISSIONS", 0),
|
||||
"the file permissions to apply to the checked-out files")
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func main() {
|
|||
for {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
|
||||
if err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest); err != nil {
|
||||
if initialSync || failCount >= *flMaxSyncFailures {
|
||||
if initialSync || (*flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures) {
|
||||
log.Errorf("error syncing repo: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue