From 02a68f482dbe8b82dedd3b197c4fc8bf8430424b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 11 Feb 2022 13:02:45 +0800 Subject: [PATCH 1/3] Fix forked repositories missed tags --- services/repository/fork.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/repository/fork.go b/services/repository/fork.go index e592e477b3bc9..99a3b775503b2 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -143,7 +143,16 @@ func ForkRepository(doer, owner *user_model.User, opts ForkRepoOptions) (_ *repo log.Error("Failed to update size for repository: %v", err) } if err := repo_model.CopyLanguageStat(opts.BaseRepo, repo); err != nil { - log.Error("Copy language stat from oldRepo failed") + log.Error("Copy language stat from oldRepo failed: %v", err) + } + + gitRepo, err := git.OpenRepository(repo.RepoPath()) + if err != nil { + log.Error("Open created git repository failed: %v", err) + } else { + if err := repo_module.SyncReleasesWithTags(repo, gitRepo); err != nil { + log.Error("Sync releases from git tags failed: %v", err) + } } notification.NotifyForkRepository(doer, opts.BaseRepo, repo) From 729ebed1beafb21c621f9bc634fac9e8c27a1cf7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 11 Feb 2022 13:04:24 +0800 Subject: [PATCH 2/3] Add missed close --- services/repository/fork.go | 1 + 1 file changed, 1 insertion(+) diff --git a/services/repository/fork.go b/services/repository/fork.go index 99a3b775503b2..d3a91a2d81f8c 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -150,6 +150,7 @@ func ForkRepository(doer, owner *user_model.User, opts ForkRepoOptions) (_ *repo if err != nil { log.Error("Open created git repository failed: %v", err) } else { + defer gitRepo.Close() if err := repo_module.SyncReleasesWithTags(repo, gitRepo); err != nil { log.Error("Sync releases from git tags failed: %v", err) } From 506c2b08fa50dd4a2e518a3c2a5c743954d5527a Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 12 Feb 2022 02:04:08 +0800 Subject: [PATCH 3/3] Use ctx --- services/repository/fork.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/repository/fork.go b/services/repository/fork.go index d3a91a2d81f8c..ec8fb1a09e708 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -146,7 +146,7 @@ func ForkRepository(doer, owner *user_model.User, opts ForkRepoOptions) (_ *repo log.Error("Copy language stat from oldRepo failed: %v", err) } - gitRepo, err := git.OpenRepository(repo.RepoPath()) + gitRepo, err := git.OpenRepositoryCtx(git.DefaultContext, repo.RepoPath()) if err != nil { log.Error("Open created git repository failed: %v", err) } else {