@@ -566,38 +566,40 @@ func main() {
566566 } else {
567567 updateSyncMetrics (metricKeyNoOp , start )
568568 }
569- }
570569
571- if initialSync {
572- // Determine if git-sync should terminate for one of several reasons
573- if * flOneTime {
574- // Wait for hooks to complete at least once, if not nil, before
575- // checking whether to stop program.
576- // Assumes that if hook channels are not nil, they will have at
577- // least one value before getting closed
578- exitCode := 0 // is 0 if all hooks succeed, else is 1
579- if exechookRunner != nil {
580- if err := exechookRunner .WaitForCompletion (); err != nil {
581- exitCode = 1
570+ if initialSync {
571+ // Determine if git-sync should terminate for one of several reasons
572+ if * flOneTime {
573+ exitCode := 0 // is 0 if all hooks succeed, else is 1
574+ if changed {
575+ // Wait for hooks to complete at least once, if not nil, before
576+ // checking whether to stop program.
577+ // Assumes that if hook channels are not nil, they will have at
578+ // least one value before getting closed
579+ if exechookRunner != nil {
580+ if err := exechookRunner .WaitForCompletion (); err != nil {
581+ exitCode = 1
582+ }
583+ }
584+ if webhookRunner != nil {
585+ if err := webhookRunner .WaitForCompletion (); err != nil {
586+ exitCode = 1
587+ }
588+ }
582589 }
590+ log .DeleteErrorFile ()
591+ os .Exit (exitCode )
583592 }
584- if webhookRunner != nil {
585- if err := webhookRunner .WaitForCompletion (); err != nil {
586- exitCode = 1
587- }
593+ if isHash , err := revIsHash (ctx , * flRev , * flRoot ); err != nil {
594+ log .Error (err , "can't tell if rev is a git hash, exiting" , "rev" , * flRev )
595+ os .Exit (1 )
596+ } else if isHash {
597+ log .V (0 ).Info ("rev appears to be a git hash, no further sync needed" , "rev" , * flRev )
598+ log .DeleteErrorFile ()
599+ sleepForever ()
588600 }
589- log .DeleteErrorFile ()
590- os .Exit (exitCode )
591- }
592- if isHash , err := revIsHash (ctx , * flRev , * flRoot ); err != nil {
593- log .Error (err , "can't tell if rev is a git hash, exiting" , "rev" , * flRev )
594- os .Exit (1 )
595- } else if isHash {
596- log .V (0 ).Info ("rev appears to be a git hash, no further sync needed" , "rev" , * flRev )
597- log .DeleteErrorFile ()
598- sleepForever ()
601+ initialSync = false
599602 }
600- initialSync = false
601603 }
602604
603605 if failCount > 0 {
0 commit comments