From 705b1e49a8b2ac8df377120f70f3548df15cdf49 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Fri, 10 Jan 2020 22:20:11 -0300 Subject: [PATCH] Don't attempt to close issue if already closed (#9696) Co-authored-by: Lauris BH --- 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 07bc1b875..3be6509bc 100644 --- a/modules/repofiles/action.go +++ b/modules/repofiles/action.go @@ -138,9 +138,11 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*r 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 b38c2e72f..7aec7cef3 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 + } } }