From a5ca193fbe030ce37494f8e084c411d9f30ce318 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 6 Jul 2023 14:24:16 +0800 Subject: [PATCH 1/2] Sync branches when mirroring --- modules/git/git.go | 3 +-- services/mirror/mirror_pull.go | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/git/git.go b/modules/git/git.go index f78a496d534c..8610f88c4ccb 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -188,7 +188,6 @@ func InitFull(ctx context.Context) (err error) { if CheckGitVersionAtLeast("2.9") == nil { globalCommandArgs = append(globalCommandArgs, "-c", "credential.helper=") } - SupportProcReceive = CheckGitVersionAtLeast("2.29") == nil if setting.LFS.StartServer { @@ -359,7 +358,7 @@ func configSetNonExist(key, value string) error { func configAddNonExist(key, value string) error { _, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil) if err == nil { - // already exist + // already exist , return nil } if err.IsExitCode(1) { diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go index 53ab632b01c1..51c7de58b645 100644 --- a/services/mirror/mirror_pull.go +++ b/services/mirror/mirror_pull.go @@ -307,6 +307,11 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo return nil, false } + log.Trace("SyncMirrors [repo: %-v]: syncing branches...", m.Repo) + if _, err = repo_module.SyncRepoBranchesWithRepo(ctx, m.Repo, gitRepo, 0); err != nil { + log.Error("SyncMirrors [repo: %-v]: failed to synchronize branches: %v", m.Repo, err) + } + log.Trace("SyncMirrors [repo: %-v]: syncing releases with tags...", m.Repo) if err = repo_module.SyncReleasesWithTags(m.Repo, gitRepo); err != nil { log.Error("SyncMirrors [repo: %-v]: failed to synchronize tags to releases: %v", m.Repo, err) From c3e75a878ea83c75d482100ec491b2681946fa2c Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Thu, 6 Jul 2023 10:07:59 +0200 Subject: [PATCH 2/2] Update modules/git/git.go --- modules/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/git.go b/modules/git/git.go index 8610f88c4ccb..c9d174e11811 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -358,7 +358,7 @@ func configSetNonExist(key, value string) error { func configAddNonExist(key, value string) error { _, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil) if err == nil { - // already exist , + // already exist return nil } if err.IsExitCode(1) {