Skip to content

Commit

Permalink
Explicitly refer to PR in squash-merge commit message in case of exte…
Browse files Browse the repository at this point in the history
…rnal tracker (#9844) (#9855)

* Explicitly refer to PR in squash-merge commit message in case of external tracker

* documentation

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
2 people authored and lunny committed Jan 18, 2020
1 parent 95cb921 commit aa6ed1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/content/doc/usage/linked-references.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit aa6ed1b

Please sign in to comment.