From 9da8e478ddbc2c3bd85d3bc5ed50475b439101ec Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 12 Feb 2022 21:48:38 +0800 Subject: [PATCH] Fix forked repositories missed tags (#18719) (#18735) * Fix forked repositories missed tags * Add missed close * Use ctx Co-authored-by: 6543 <6543@obermui.de> --- services/repository/fork.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/repository/fork.go b/services/repository/fork.go index b091ca8fd..493a955e0 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -143,7 +143,17 @@ 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.OpenRepositoryCtx(git.DefaultContext, repo.RepoPath()) + 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) + } } notification.NotifyForkRepository(doer, opts.BaseRepo, repo)