@@ -771,7 +771,7 @@ func main() {
771771 }
772772
773773 failCount := 0
774- firstLoop := true
774+ syncCount := uint64 ( 0 )
775775 for {
776776 start := time .Now ()
777777 ctx , cancel := context .WithTimeout (context .Background (), * flSyncTimeout )
@@ -789,7 +789,7 @@ func main() {
789789 // this might have been called before, but also might not have
790790 setRepoReady ()
791791 // We treat the first loop as a sync, including sending hooks.
792- if changed || firstLoop {
792+ if changed || syncCount == 0 {
793793 if absTouchFile != "" {
794794 if err := touch (absTouchFile ); err != nil {
795795 log .Error (err , "failed to touch touch-file" , "path" , absTouchFile )
@@ -807,7 +807,7 @@ func main() {
807807 } else {
808808 updateSyncMetrics (metricKeyNoOp , start )
809809 }
810- firstLoop = false
810+ syncCount ++
811811
812812 // Clean up old worktree(s) and run GC.
813813 if err := git .cleanup (ctx ); err != nil {
@@ -852,7 +852,7 @@ func main() {
852852 log .DeleteErrorFile ()
853853 }
854854
855- log .V (3 ).Info ("next sync" , "waitTime" , flPeriod .String ())
855+ log .V (3 ).Info ("next sync" , "waitTime" , flPeriod .String (), "syncCount" , syncCount )
856856 cancel ()
857857
858858 // Sleep until the next sync. If syncSig is set then the sleep may
@@ -1076,7 +1076,7 @@ func (git *repoSync) initRepo(ctx context.Context) error {
10761076 // the contents rather than the dir itself, because a common use-case
10771077 // is to have a volume mounted at git.root, which makes removing it
10781078 // impossible.
1079- git .log .V (0 ).Info ("repo directory failed checks or was empty " , "path" , git .root )
1079+ git .log .V (0 ).Info ("repo directory was empty or failed checks " , "path" , git .root )
10801080 if err := removeDirContents (git .root , git .log ); err != nil {
10811081 return fmt .Errorf ("can't wipe unusable root directory: %w" , err )
10821082 }
0 commit comments