From 29179ed6a038fe5a61ff3d16933b1d0682ae0580 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 20 Aug 2024 09:33:33 +0800 Subject: [PATCH 1/2] handle close references for manual merges --- services/pull/merge.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/pull/merge.go b/services/pull/merge.go index e19292c31ca99..437a828c51871 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -219,6 +219,14 @@ func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.U // Reset cached commit count cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true)) + if err := handleCloseCrossReferences(ctx, pr, doer); err != nil { + return err + } + + return nil +} + +func handleCloseCrossReferences(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User) error { // Resolve cross references refs, err := pr.ResolveCrossReferences(ctx) if err != nil { @@ -542,5 +550,10 @@ func MergedManually(ctx context.Context, pr *issues_model.PullRequest, doer *use notify_service.MergePullRequest(baseGitRepo.Ctx, doer, pr) log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commitID) + + if err := handleCloseCrossReferences(ctx, pr, doer); err != nil { + return err + } + return nil } From e068cb16a910d9c4e67b75c6964d9c1c82b852da Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 20 Aug 2024 09:42:53 +0800 Subject: [PATCH 2/2] lint --- services/pull/merge.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/services/pull/merge.go b/services/pull/merge.go index 437a828c51871..eb67e0694615d 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -219,11 +219,7 @@ func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.U // Reset cached commit count cache.Remove(pr.Issue.Repo.GetCommitsCountCacheKey(pr.BaseBranch, true)) - if err := handleCloseCrossReferences(ctx, pr, doer); err != nil { - return err - } - - return nil + return handleCloseCrossReferences(ctx, pr, doer) } func handleCloseCrossReferences(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User) error { @@ -551,9 +547,5 @@ func MergedManually(ctx context.Context, pr *issues_model.PullRequest, doer *use notify_service.MergePullRequest(baseGitRepo.Ctx, doer, pr) log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commitID) - if err := handleCloseCrossReferences(ctx, pr, doer); err != nil { - return err - } - - return nil + return handleCloseCrossReferences(ctx, pr, doer) }