mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Backport #30432 Fix https://github.com/go-gitea/gitea/issues/30424 ps: convert `gitrepo.OpenRepository` to `git.OpenRepository` remove `ctx` from `checkAndUpdateEmptyRepository` Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		@@ -449,19 +449,17 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
 | 
				
			|||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var gitRepo *git.Repository
 | 
						gitRepo, err := git.OpenRepository(ctx, m.Repo.RepoPath())
 | 
				
			||||||
	if len(results) == 0 {
 | 
					 | 
				
			||||||
		log.Trace("SyncMirrors [repo: %-v]: no branches updated", m.Repo)
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		log.Trace("SyncMirrors [repo: %-v]: %d branches updated", m.Repo, len(results))
 | 
					 | 
				
			||||||
		gitRepo, err = git.OpenRepository(ctx, m.Repo.RepoPath())
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Error("SyncMirrors [repo: %-v]: unable to OpenRepository: %v", m.Repo, err)
 | 
							log.Error("SyncMirrors [repo: %-v]: unable to OpenRepository: %v", m.Repo, err)
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	defer gitRepo.Close()
 | 
						defer gitRepo.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log.Trace("SyncMirrors [repo: %-v]: %d branches updated", m.Repo, len(results))
 | 
				
			||||||
 | 
						if len(results) > 0 {
 | 
				
			||||||
		if ok := checkAndUpdateEmptyRepository(m, gitRepo, results); !ok {
 | 
							if ok := checkAndUpdateEmptyRepository(m, gitRepo, results); !ok {
 | 
				
			||||||
 | 
								log.Error("SyncMirrors [repo: %-v]: checkAndUpdateEmptyRepository: %v", m.Repo, err)
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -533,6 +531,12 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	log.Trace("SyncMirrors [repo: %-v]: done notifying updated branches/tags - now updating last commit time", m.Repo)
 | 
						log.Trace("SyncMirrors [repo: %-v]: done notifying updated branches/tags - now updating last commit time", m.Repo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						isEmpty, err := gitRepo.IsEmpty()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Error("SyncMirrors [repo: %-v]: unable to check empty git repo: %v", m.Repo, err)
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if !isEmpty {
 | 
				
			||||||
		// Get latest commit date and update to current repository updated time
 | 
							// Get latest commit date and update to current repository updated time
 | 
				
			||||||
		commitDate, err := git.GetLatestCommitTime(ctx, m.Repo.RepoPath())
 | 
							commitDate, err := git.GetLatestCommitTime(ctx, m.Repo.RepoPath())
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
@@ -545,6 +549,8 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
 | 
				
			|||||||
			return false
 | 
								return false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Trace("SyncMirrors [repo: %-v]: Successfully updated", m.Repo)
 | 
						log.Trace("SyncMirrors [repo: %-v]: Successfully updated", m.Repo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user