From 281029529bf98218b6c75353f2fce2d74b7ba196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=BA=E8=B6=85?= <1012112796@qq.com> Date: Tue, 14 Apr 2020 09:06:23 +0800 Subject: [PATCH] ui: Add MergePull comment type instead of close for merge PR (#11058) Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: Lauris BH --- models/issue.go | 6 ++++-- models/issue_comment.go | 2 ++ models/pull.go | 2 +- options/locale/locale_en-US.ini | 1 + templates/repo/issue/view_content/comments.tmpl | 14 +++++++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/models/issue.go b/models/issue.go index ba211e967..17ec0a688 100644 --- a/models/issue.go +++ b/models/issue.go @@ -554,7 +554,7 @@ func updateIssueCols(e Engine, issue *Issue, cols ...string) error { return nil } -func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*Comment, error) { +func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed, isMergePull bool) (*Comment, error) { // Reload the issue currentIssue, err := getIssueByID(e, issue.ID) if err != nil { @@ -620,6 +620,8 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*C cmtType := CommentTypeClose if !issue.IsClosed { cmtType = CommentTypeReopen + } else if isMergePull { + cmtType = CommentTypeMergePull } return createComment(e, &CreateCommentOptions{ @@ -645,7 +647,7 @@ func (issue *Issue) ChangeStatus(doer *User, isClosed bool) (*Comment, error) { return nil, err } - comment, err := issue.changeStatus(sess, doer, isClosed) + comment, err := issue.changeStatus(sess, doer, isClosed, false) if err != nil { return nil, err } diff --git a/models/issue_comment.go b/models/issue_comment.go index f522604af..2e59a2cb3 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -88,6 +88,8 @@ const ( CommentTypeDeleteTimeManual // add or remove Request from one CommentTypeReviewRequest + // merge pull request + CommentTypeMergePull ) // CommentTag defines comment tag type diff --git a/models/pull.go b/models/pull.go index 02b5e98c4..055f9bbc6 100644 --- a/models/pull.go +++ b/models/pull.go @@ -390,7 +390,7 @@ func (pr *PullRequest) SetMerged() (bool, error) { return false, err } - if _, err := pr.Issue.changeStatus(sess, pr.Merger, true); err != nil { + if _, err := pr.Issue.changeStatus(sess, pr.Merger, true, true); err != nil { return false, fmt.Errorf("Issue.changeStatus: %v", err) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 9a1a458f6..8b43115c0 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -925,6 +925,7 @@ issues.context.edit = Edit issues.context.delete = Delete issues.no_content = There is no content yet. issues.close_issue = Close +issues.pull_merged_at = `merged commit %[2]s into %[3]s %[4]s` issues.close_comment_issue = Comment and Close issues.reopen_issue = Reopen issues.reopen_comment_issue = Comment and Reopen diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index dc7d2db3c..da1483ec3 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -7,7 +7,7 @@ 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE, 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE, 22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED, - 26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST --> + 26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST, 28 = MERGE_PULL_REQUEST --> {{if eq .Type 0}}
{{if .OriginalAuthor }} @@ -84,6 +84,18 @@ {{.Poster.GetDisplayName}} {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}
+ {{else if eq .Type 28}} +
+ {{svg "octicon-git-merge" 16}} + + + + + {{.Poster.GetDisplayName}} + {{$link := printf "%s/commit/%s" $.Repository.HTMLURL $.Issue.PullRequest.MergedCommitID}} + {{$.i18n.Tr "repo.issues.pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) $.BaseTarget $createdStr | Str2html}} + +
{{else if eq .Type 3 5 6}} {{ $refFrom:= "" }} {{if ne .RefRepoID .Issue.RepoID}}