Skip to content

Commit 2810295

Browse files
a1012112796lafriks
andauthored
ui: Add MergePull comment type instead of close for merge PR (#11058)
Signed-off-by: a1012112796 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 063b1d2 commit 2810295

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

models/issue.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
554554
return nil
555555
}
556556

557-
func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*Comment, error) {
557+
func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed, isMergePull bool) (*Comment, error) {
558558
// Reload the issue
559559
currentIssue, err := getIssueByID(e, issue.ID)
560560
if err != nil {
@@ -620,6 +620,8 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*C
620620
cmtType := CommentTypeClose
621621
if !issue.IsClosed {
622622
cmtType = CommentTypeReopen
623+
} else if isMergePull {
624+
cmtType = CommentTypeMergePull
623625
}
624626

625627
return createComment(e, &CreateCommentOptions{
@@ -645,7 +647,7 @@ func (issue *Issue) ChangeStatus(doer *User, isClosed bool) (*Comment, error) {
645647
return nil, err
646648
}
647649

648-
comment, err := issue.changeStatus(sess, doer, isClosed)
650+
comment, err := issue.changeStatus(sess, doer, isClosed, false)
649651
if err != nil {
650652
return nil, err
651653
}

models/issue_comment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const (
8888
CommentTypeDeleteTimeManual
8989
// add or remove Request from one
9090
CommentTypeReviewRequest
91+
// merge pull request
92+
CommentTypeMergePull
9193
)
9294

9395
// CommentTag defines comment tag type

models/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (pr *PullRequest) SetMerged() (bool, error) {
390390
return false, err
391391
}
392392

393-
if _, err := pr.Issue.changeStatus(sess, pr.Merger, true); err != nil {
393+
if _, err := pr.Issue.changeStatus(sess, pr.Merger, true, true); err != nil {
394394
return false, fmt.Errorf("Issue.changeStatus: %v", err)
395395
}
396396

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ issues.context.edit = Edit
925925
issues.context.delete = Delete
926926
issues.no_content = There is no content yet.
927927
issues.close_issue = Close
928+
issues.pull_merged_at = `merged commit <a href="%[1]s">%[2]s</a> into <b>%[3]s</b> %[4]s`
928929
issues.close_comment_issue = Comment and Close
929930
issues.reopen_issue = Reopen
930931
issues.reopen_comment_issue = Comment and Reopen

templates/repo/issue/view_content/comments.tmpl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
88
18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
99
22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED,
10-
26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST -->
10+
26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST, 28 = MERGE_PULL_REQUEST -->
1111
{{if eq .Type 0}}
1212
<div class="timeline-item comment" id="{{.HashTag}}">
1313
{{if .OriginalAuthor }}
@@ -84,6 +84,18 @@
8484
</a>
8585
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}</span>
8686
</div>
87+
{{else if eq .Type 28}}
88+
<div class="timeline-item event" id="{{.HashTag}}">
89+
<span class="badge purple">{{svg "octicon-git-merge" 16}}</span>
90+
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
91+
<img src="{{.Poster.RelAvatarLink}}">
92+
</a>
93+
<span class="text grey">
94+
<a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
95+
{{$link := printf "%s/commit/%s" $.Repository.HTMLURL $.Issue.PullRequest.MergedCommitID}}
96+
{{$.i18n.Tr "repo.issues.pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) $.BaseTarget $createdStr | Str2html}}
97+
</span>
98+
</div>
8799
{{else if eq .Type 3 5 6}}
88100
{{ $refFrom:= "" }}
89101
{{if ne .RefRepoID .Issue.RepoID}}

0 commit comments

Comments
 (0)