summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorguillep2k <18600385+guillep2k@users.noreply.github.com>2019-11-18 10:13:07 -0300
committerLauris BH <lauris@nix.lv>2019-11-18 15:13:07 +0200
commitb15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6 (patch)
tree14e4b0e743605f25da792c96c6deb2d5e8200155 /services
parent08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc (diff)
downloadgitea-b15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6.tar.gz
gitea-b15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6.zip
Close/reopen issues by keywords in titles and comments (#8866)
* Add close/reopen from comment functionality * Fix comment * Rewrite closing/reopening template * Check xref permissions, move action to services/pull * Fix RefIsPull field * Add xref tests * Fix xref unique filter * Only highlight keywords for actionable xrefs * Fix xref neuter filter * Fix check return status * Restart CI
Diffstat (limited to 'services')
-rw-r--r--services/pull/merge.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/services/pull/merge.go b/services/pull/merge.go
index 7dc3c07338..8ae5f029e8 100644
--- a/services/pull/merge.go
+++ b/services/pull/merge.go
@@ -21,8 +21,10 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
+ "code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
+ issue_service "code.gitea.io/gitea/services/issue"
"github.com/mcuadros/go-version"
)
@@ -447,6 +449,26 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
notification.NotifyIssueChangeStatus(doer, pr.Issue, true)
+ // Resolve cross references
+ refs, err := pr.ResolveCrossReferences()
+ if err != nil {
+ log.Error("ResolveCrossReferences: %v", err)
+ return nil
+ }
+
+ for _, ref := range refs {
+ if err = ref.LoadIssue(); err != nil {
+ return err
+ }
+ if err = ref.Issue.LoadRepo(); err != nil {
+ return err
+ }
+ close := (ref.RefAction == references.XRefActionCloses)
+ if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil {
+ return err
+ }
+ }
+
return nil
}