From ff16099c6da1dd83b8de68842216e2294a5e7447 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Sat, 11 Jan 2020 03:42:11 -0300 Subject: [PATCH] Don't attempt to close issue if already closed (#9699) --- modules/repofiles/action.go | 8 +++++--- services/pull/merge.go | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/repofiles/action.go b/modules/repofiles/action.go index d207247114..5fe9333591 100644 --- a/modules/repofiles/action.go +++ b/modules/repofiles/action.go @@ -137,9 +137,11 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*m continue } } - - if err := changeIssueStatus(refRepo, refIssue, doer, ref.Action == references.XRefActionCloses); err != nil { - return err + close := (ref.Action == references.XRefActionCloses) + if close != refIssue.IsClosed { + if err := changeIssueStatus(refRepo, refIssue, doer, close); err != nil { + return err + } } } } diff --git a/services/pull/merge.go b/services/pull/merge.go index 8aa38bf11e..65a781e54c 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -374,8 +374,10 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor return err } close := (ref.RefAction == references.XRefActionCloses) - if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil { - return err + if close != ref.Issue.IsClosed { + if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil { + return err + } } }