@@ -157,6 +157,25 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
157
157
refName : refName ,
158
158
newCommitID : gitShortEmptySha ,
159
159
})
160
+ case strings .HasPrefix (lines [i ], " + " ): // Force update
161
+ if idx := strings .Index (refName , " " ); idx > - 1 {
162
+ refName = refName [:idx ]
163
+ }
164
+ delimIdx := strings .Index (lines [i ][3 :], " " )
165
+ if delimIdx == - 1 {
166
+ log .Error ("SHA delimiter not found: %q" , lines [i ])
167
+ continue
168
+ }
169
+ shas := strings .Split (lines [i ][3 :delimIdx + 3 ], "..." )
170
+ if len (shas ) != 2 {
171
+ log .Error ("Expect two SHAs but not what found: %q" , lines [i ])
172
+ continue
173
+ }
174
+ results = append (results , & mirrorSyncResult {
175
+ refName : refName ,
176
+ oldCommitID : shas [0 ],
177
+ newCommitID : shas [1 ],
178
+ })
160
179
case strings .HasPrefix (lines [i ], " " ): // New commits of a reference
161
180
delimIdx := strings .Index (lines [i ][3 :], " " )
162
181
if delimIdx == - 1 {
@@ -187,6 +206,7 @@ func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
187
206
wikiPath := m .Repo .WikiPath ()
188
207
timeout := time .Duration (setting .Git .Timeout .Mirror ) * time .Second
189
208
209
+ log .Trace ("SyncMirrors [repo: %-v]: running git remote update..." , m .Repo )
190
210
gitArgs := []string {"remote" , "update" }
191
211
if m .EnablePrune {
192
212
gitArgs = append (gitArgs , "--prune" )
@@ -228,17 +248,21 @@ func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
228
248
log .Error ("OpenRepository: %v" , err )
229
249
return nil , false
230
250
}
251
+
252
+ log .Trace ("SyncMirrors [repo: %-v]: syncing releases with tags..." , m .Repo )
231
253
if err = repo_module .SyncReleasesWithTags (m .Repo , gitRepo ); err != nil {
232
254
gitRepo .Close ()
233
255
log .Error ("Failed to synchronize tags to releases for repository: %v" , err )
234
256
}
235
257
gitRepo .Close ()
236
258
259
+ log .Trace ("SyncMirrors [repo: %-v]: updating size of repository" , m .Repo )
237
260
if err := m .Repo .UpdateSize (models .DefaultDBContext ()); err != nil {
238
261
log .Error ("Failed to update size for mirror repository: %v" , err )
239
262
}
240
263
241
264
if m .Repo .HasWiki () {
265
+ log .Trace ("SyncMirrors [repo: %-v Wiki]: running git remote update..." , m .Repo )
242
266
stderrBuilder .Reset ()
243
267
stdoutBuilder .Reset ()
244
268
if err := git .NewCommand ("remote" , "update" , "--prune" ).
@@ -268,8 +292,10 @@ func runSync(m *models.Mirror) ([]*mirrorSyncResult, bool) {
268
292
}
269
293
return nil , false
270
294
}
295
+ log .Trace ("SyncMirrors [repo: %-v Wiki]: git remote update complete" , m .Repo )
271
296
}
272
297
298
+ log .Trace ("SyncMirrors [repo: %-v]: invalidating mirror branch caches..." , m .Repo )
273
299
branches , err := repo_module .GetBranches (m .Repo )
274
300
if err != nil {
275
301
log .Error ("GetBranches: %v" , err )
@@ -371,11 +397,13 @@ func syncMirror(repoID string) {
371
397
372
398
}
373
399
400
+ log .Trace ("SyncMirrors [repo: %-v]: Running Sync" , m .Repo )
374
401
results , ok := runSync (m )
375
402
if ! ok {
376
403
return
377
404
}
378
405
406
+ log .Trace ("SyncMirrors [repo: %-v]: Scheduling next update" , m .Repo )
379
407
m .ScheduleNextUpdate ()
380
408
if err = models .UpdateMirror (m ); err != nil {
381
409
log .Error ("UpdateMirror [%s]: %v" , repoID , err )
@@ -384,8 +412,9 @@ func syncMirror(repoID string) {
384
412
385
413
var gitRepo * git.Repository
386
414
if len (results ) == 0 {
387
- log .Trace ("SyncMirrors [repo_id : %d ]: no commits fetched " , m .RepoID )
415
+ log .Trace ("SyncMirrors [repo : %-v ]: no branches updated " , m .Repo )
388
416
} else {
417
+ log .Trace ("SyncMirrors [repo: %-v]: %d branches updated" , m .Repo , len (results ))
389
418
gitRepo , err = git .OpenRepository (m .Repo .RepoPath ())
390
419
if err != nil {
391
420
log .Error ("OpenRepository [%d]: %v" , m .RepoID , err )
@@ -440,6 +469,7 @@ func syncMirror(repoID string) {
440
469
441
470
notification .NotifySyncPushCommits (m .Repo .MustOwner (), m .Repo , result .refName , oldCommitID , newCommitID , theCommits )
442
471
}
472
+ log .Trace ("SyncMirrors [repo: %-v]: done notifying updated branches/tags - now updating last commit time" , m .Repo )
443
473
444
474
// Get latest commit date and update to current repository updated time
445
475
commitDate , err := git .GetLatestCommitTime (m .Repo .RepoPath ())
@@ -452,6 +482,8 @@ func syncMirror(repoID string) {
452
482
log .Error ("Update repository 'updated_unix' [%d]: %v" , m .RepoID , err )
453
483
return
454
484
}
485
+
486
+ log .Trace ("SyncMirrors [repo: %-v]: Successfully updated" , m .Repo )
455
487
}
456
488
457
489
// InitSyncMirrors initializes a go routine to sync the mirrors
0 commit comments