From aa6ed1b7c138ec45362bcbebb72e58baeaf2a2be Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Sat, 18 Jan 2020 15:28:33 +0100 Subject: [PATCH] Explicitly refer to PR in squash-merge commit message in case of external tracker (#9844) (#9855) * Explicitly refer to PR in squash-merge commit message in case of external tracker * documentation Co-authored-by: zeripath Co-authored-by: zeripath --- docs/content/doc/usage/linked-references.en-us.md | 3 ++- models/pull.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/content/doc/usage/linked-references.en-us.md b/docs/content/doc/usage/linked-references.en-us.md index a5f88363dd..d2836f8571 100644 --- a/docs/content/doc/usage/linked-references.en-us.md +++ b/docs/content/doc/usage/linked-references.en-us.md @@ -136,7 +136,8 @@ the `!` marker to identify pull requests. For example: > This is pull request [!1234](#), and links to a pull request in Gitea. The `!` and `#` can be used interchangeably for issues and pull request _except_ -for this case, where a distinction is required. +for this case, where a distinction is required. If the repository uses external +tracker, commit message for squash merge will use `!` as reference by default. ## Issues and Pull Requests References Summary diff --git a/models/pull.go b/models/pull.go index 94cb2a2a03..870a0960df 100644 --- a/models/pull.go +++ b/models/pull.go @@ -385,6 +385,13 @@ func (pr *PullRequest) GetDefaultSquashMessage() string { log.Error("LoadIssue: %v", err) return "" } + if err := pr.LoadBaseRepo(); err != nil { + log.Error("LoadBaseRepo: %v", err) + return "" + } + if pr.BaseRepo.UnitEnabled(UnitTypeExternalTracker) { + return fmt.Sprintf("%s (!%d)", pr.Issue.Title, pr.Issue.Index) + } return fmt.Sprintf("%s (#%d)", pr.Issue.Title, pr.Issue.Index) }