@@ -97,13 +97,12 @@ func (r *RepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request)
9797 return ctrl.Result {}, client .IgnoreNotFound (err )
9898 }
9999
100+ defer r .postProcessReconcile (ctx , req , & gitRepo )
100101 if ! r .shouldProcess (gitRepo ) {
101102 return ctrl.Result {Requeue : false }, nil
102103 }
103104
104105 logger .Info ("reconciling GitRepository" , "name" , req .Name , "namespace" , req .Namespace )
105- defer r .postProcessReconcile (ctx , req , & gitRepo )
106-
107106 result , err := r .reconcileGitRepo (ctx , & gitRepo )
108107 if err != nil {
109108 r .Recorder .Event (& gitRepo , "Warning" , "reconcile error" , err .Error ())
@@ -116,16 +115,22 @@ func (r *RepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request)
116115
117116func (r * RepositoryReconciler ) postProcessReconcile (ctx context.Context , req ctrl.Request , repo * v1alpha1.GitRepository ) {
118117 logger := log .FromContext (ctx )
118+
119119 err := r .Status ().Update (ctx , repo )
120120 if err != nil {
121121 logger .Error (err , "failed updating repo status" )
122122 }
123+
124+ err = util .UpdateSyncAnnotation (ctx , r .Client , repo )
125+ if err != nil {
126+ logger .Error (err , "failed updating repo annotation" )
127+ }
123128}
124129
125130func (r * RepositoryReconciler ) reconcileGitRepo (ctx context.Context , repo * v1alpha1.GitRepository ) (ctrl.Result , error ) {
126131 logger := log .FromContext (ctx )
127132 logger .Info ("reconciling" , "name" , repo .Name , "dir" , repo .Spec .Source )
128-
133+ repo . Status . Synced = false
129134 tr := & http.Transport {
130135 TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
131136 }
@@ -147,13 +152,14 @@ func (r *RepositoryReconciler) reconcileGitRepo(ctx context.Context, repo *v1alp
147152 if err != nil {
148153 return ctrl.Result {Requeue : true , RequeueAfter : requeueTime }, fmt .Errorf ("failed to create or update repo %w" , err )
149154 }
150- repo .Status .ExternalGitRepositoryUrl = giteaRepo .CloneURL
151- repo .Status .InternalGitRepositoryUrl = getRepositoryURL (repo .Namespace , repo .Name , repo .Spec .InternalGitURL )
152155
153156 err = r .reconcileRepoContent (ctx , repo , giteaRepo )
154157 if err != nil {
155158 return ctrl.Result {Requeue : true , RequeueAfter : requeueTime }, fmt .Errorf ("failed to reconcile repo content %w" , err )
156159 }
160+
161+ repo .Status .ExternalGitRepositoryUrl = giteaRepo .CloneURL
162+ repo .Status .InternalGitRepositoryUrl = getRepositoryURL (repo .Namespace , repo .Name , repo .Spec .InternalGitURL )
157163 repo .Status .Synced = true
158164 return ctrl.Result {Requeue : true , RequeueAfter : requeueTime }, nil
159165}
0 commit comments