From cf2e82ee51eb08daceeb854cc8f4ec0019fc1536 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Mon, 10 Feb 2020 22:04:29 +0000 Subject: [PATCH 1/4] Add Approval Counts to pulls list Add simple approvals counts to pulls lists --- models/issue_list.go | 33 ++++++++++++++++++++++++++++ models/pull.go | 19 ++++++++++++++++ options/locale/locale_en-US.ini | 9 ++++++++ routers/repo/issue.go | 22 +++++++++++++++++++ routers/user/home.go | 22 +++++++++++++++++++ templates/repo/issue/list.tmpl | 15 +++++++++++++ templates/user/dashboard/issues.tmpl | 15 +++++++++++++ 7 files changed, 135 insertions(+) diff --git a/models/issue_list.go b/models/issue_list.go index 4554f906c48c3..126f56f39521c 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -515,3 +515,36 @@ func (issues IssueList) LoadComments() error { func (issues IssueList) LoadDiscussComments() error { return issues.loadComments(x, builder.Eq{"comment.type": CommentTypeComment}) } + +// GetApprovalCounts returns a map of issue ID to slice of approval counts +func (issues IssueList) GetApprovalCounts() (map[int64][]*ReviewCount, error) { + return issues.getApprovalCounts(x) +} + +func (issues IssueList) getApprovalCounts(e Engine) (map[int64][]*ReviewCount, error) { + rCounts := make([]*ReviewCount, 0, 6*len(issues)) + ids := make([]int64, len(issues)) + for i, issue := range issues { + ids[i] = issue.ID + } + sess := e.In("issue_id", ids) + err := sess.Select("issue_id, type, official, count(id) as `count`").GroupBy("issue_id, type, official").OrderBy("issue_id").Table("review").Find(&rCounts) + if err != nil { + return nil, err + } + + approvalCountMap := make(map[int64][]*ReviewCount, len(issues)) + if len(rCounts) > 0 { + start := 0 + lastID := rCounts[0].IssueID + for i, current := range rCounts[1:] { + if lastID != current.IssueID { + approvalCountMap[lastID] = rCounts[start:i] + start = i + lastID = current.IssueID + } + } + approvalCountMap[lastID] = rCounts[start:] + } + return approvalCountMap, nil +} diff --git a/models/pull.go b/models/pull.go index 46c50986b92b1..0afdf52ac8de0 100644 --- a/models/pull.go +++ b/models/pull.go @@ -330,6 +330,25 @@ func (pr *PullRequest) GetCommitMessages() string { return stringBuilder.String() } +// ReviewCount represents a count of Reviews +type ReviewCount struct { + IssueID int64 + Type ReviewType + Official bool + Count int64 +} + +// GetApprovalCounts returns the approval counts by type +func (pr *PullRequest) GetApprovalCounts() ([]*ReviewCount, error) { + return pr.getApprovalCounts(x) +} + +func (pr *PullRequest) getApprovalCounts(e Engine) ([]*ReviewCount, error) { + rCounts := make([]*ReviewCount, 0, 6) + sess := e.Where("issue_id = ?", pr.IssueID) + return rCounts, sess.Select("issue_id, type, official, count(id) as `count`").GroupBy("issue_id, type, official").Table("review").Find(&rCounts) +} + // GetApprovers returns the approvers of the pull request func (pr *PullRequest) GetApprovers() string { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index dbd1a3680d595..25cd20b20bd66 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1071,6 +1071,15 @@ pulls.cannot_auto_merge_desc = This pull request cannot be merged automatically pulls.cannot_auto_merge_helper = Merge manually to resolve the conflicts. pulls.num_conflicting_files_1 = "%d conflicting file" pulls.num_conflicting_files_n = "%d conflicting files" +pulls.approve_count_1 = "%d approval" +pulls.approve_count_n = "%d approvals" +pulls.approve_non_official_count_1 = "+%d non-official" +pulls.approve_non_official_count_n = "+%d non-official" +pulls.reject_count_1 = "%d change request" +pulls.reject_count_n = "%d change requests" +pulls.reject_non_official_count_1 = "+%d non-official" +pulls.reject_non_official_count_n = "+%d non-official" + pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled. pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually. pulls.no_merge_wip = This pull request can not be merged because it is marked as being a work in progress. diff --git a/routers/repo/issue.go b/routers/repo/issue.go index fdade2795d164..7e84b5c5db75b 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -216,6 +216,12 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB } } + approvalCounts, err := models.IssueList(issues).GetApprovalCounts() + if err != nil { + ctx.ServerError("ApprovalCounts", err) + return + } + var commitStatus = make(map[int64]*models.CommitStatus, len(issues)) // Get posters. @@ -263,6 +269,22 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB assigneeID = 0 // Reset ID to prevent unexpected selection of assignee. } + ctx.Data["ApprovalCounts"] = func(issueID int64, typ string, official bool) int64 { + counts, ok := approvalCounts[issueID] + if !ok || len(counts) == 0 { + return 0 + } + reviewTyp := models.ReviewTypeApprove + if typ == "reject" { + reviewTyp = models.ReviewTypeReject + } + for _, count := range counts { + if count.Type == reviewTyp && count.Official == official { + return count.Count + } + } + return 0 + } ctx.Data["IssueStats"] = issueStats ctx.Data["SelLabelIDs"] = labelIDs ctx.Data["SelectLabels"] = selectLabels diff --git a/routers/user/home.go b/routers/user/home.go index 6b71c51de32a5..66de3851089ba 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -494,6 +494,12 @@ func Issues(ctx *context.Context) { return } + approvalCounts, err := models.IssueList(issues).GetApprovalCounts() + if err != nil { + ctx.ServerError("ApprovalCounts", err) + return + } + showReposMap := make(map[int64]*models.Repository, len(counts)) for repoID := range counts { if repoID > 0 { @@ -577,6 +583,22 @@ func Issues(ctx *context.Context) { } ctx.Data["Issues"] = issues + ctx.Data["ApprovalCounts"] = func(issueID int64, typ string, official bool) int64 { + counts, ok := approvalCounts[issueID] + if !ok || len(counts) == 0 { + return 0 + } + reviewTyp := models.ReviewTypeApprove + if typ == "reject" { + reviewTyp = models.ReviewTypeReject + } + for _, count := range counts { + if count.Type == reviewTyp && count.Official == official { + return count.Count + } + } + return 0 + } ctx.Data["CommitStatus"] = commitStatus ctx.Data["Repos"] = showRepos ctx.Data["Counts"] = counts diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 0b618daaa9d65..994bdaf3a52ca 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -202,6 +202,7 @@
+ {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}}
  • {{if $.CanWriteIssuesOrPulls}} @@ -268,6 +269,20 @@ {{end}} {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve" true}} + {{$approveNonOfficial := call $approvalCounts .ID "approve" false}} + {{$rejectOfficial := call $approvalCounts .ID "reject" true}} + {{$rejectNonOfficial := call $approvalCounts .ID "reject" false}} + {{if or (gt $approveOfficial 0) (gt $approveNonOfficial 0) (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if gt $approveNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $approveNonOfficial "repo.pulls.approve_non_official_count_1" "repo.pulls.approve_non_official_count_n") $approveNonOfficial}}){{end}} + {{if or (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{if gt $rejectNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $rejectNonOfficial "repo.pulls.reject_non_official_count_1" "repo.pulls.reject_non_official_count_n") $rejectNonOfficial}}){{end}} + {{end}} + {{end}} {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index dfb94560e5641..bdd5ea925f0ef 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -83,6 +83,7 @@
  • + {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}} {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }} @@ -152,6 +153,20 @@ {{end}} {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve" true}} + {{$approveNonOfficial := call $approvalCounts .ID "approve" false}} + {{$rejectOfficial := call $approvalCounts .ID "reject" true}} + {{$rejectNonOfficial := call $approvalCounts .ID "reject" false}} + {{if or (gt $approveOfficial 0) (gt $approveNonOfficial 0) (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if gt $approveNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $approveNonOfficial "repo.pulls.approve_non_official_count_1" "repo.pulls.approve_non_official_count_n") $approveNonOfficial}}){{end}} + {{if or (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{if gt $rejectNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $rejectNonOfficial "repo.pulls.reject_non_official_count_1" "repo.pulls.reject_non_official_count_n") $rejectNonOfficial}}){{end}} + {{end}} + {{end}} {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} From c0f692ad5dddc8aa47c84b20fdc33b0a927588b9 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 29 Feb 2020 08:57:27 +0000 Subject: [PATCH 2/4] Remove non-official counts --- models/issue_list.go | 3 ++- models/pull.go | 10 +++++----- options/locale/locale_en-US.ini | 4 ---- routers/repo/issue.go | 4 ++-- routers/user/home.go | 4 ++-- templates/repo/issue/list.tmpl | 12 ++++-------- templates/user/dashboard/issues.tmpl | 10 +++------- 7 files changed, 18 insertions(+), 29 deletions(-) diff --git a/models/issue_list.go b/models/issue_list.go index 126f56f39521c..e6ca3fc89046a 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -517,6 +517,7 @@ func (issues IssueList) LoadDiscussComments() error { } // GetApprovalCounts returns a map of issue ID to slice of approval counts +// FIXME: only returns official counts due to double counting of non-official approvals func (issues IssueList) GetApprovalCounts() (map[int64][]*ReviewCount, error) { return issues.getApprovalCounts(x) } @@ -528,7 +529,7 @@ func (issues IssueList) getApprovalCounts(e Engine) (map[int64][]*ReviewCount, e ids[i] = issue.ID } sess := e.In("issue_id", ids) - err := sess.Select("issue_id, type, official, count(id) as `count`").GroupBy("issue_id, type, official").OrderBy("issue_id").Table("review").Find(&rCounts) + err := sess.Select("issue_id, type, count(id) as `count`").Where("official = ?", true).GroupBy("issue_id, type").OrderBy("issue_id").Table("review").Find(&rCounts) if err != nil { return nil, err } diff --git a/models/pull.go b/models/pull.go index 0afdf52ac8de0..a7cc3d9c0ba71 100644 --- a/models/pull.go +++ b/models/pull.go @@ -332,13 +332,13 @@ func (pr *PullRequest) GetCommitMessages() string { // ReviewCount represents a count of Reviews type ReviewCount struct { - IssueID int64 - Type ReviewType - Official bool - Count int64 + IssueID int64 + Type ReviewType + Count int64 } // GetApprovalCounts returns the approval counts by type +// FIXME: Only returns official counts due to double counting of non-official counts func (pr *PullRequest) GetApprovalCounts() ([]*ReviewCount, error) { return pr.getApprovalCounts(x) } @@ -346,7 +346,7 @@ func (pr *PullRequest) GetApprovalCounts() ([]*ReviewCount, error) { func (pr *PullRequest) getApprovalCounts(e Engine) ([]*ReviewCount, error) { rCounts := make([]*ReviewCount, 0, 6) sess := e.Where("issue_id = ?", pr.IssueID) - return rCounts, sess.Select("issue_id, type, official, count(id) as `count`").GroupBy("issue_id, type, official").Table("review").Find(&rCounts) + return rCounts, sess.Select("issue_id, type, count(id) as `count`").Where("official = ?", true).GroupBy("issue_id, type").Table("review").Find(&rCounts) } // GetApprovers returns the approvers of the pull request diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 25cd20b20bd66..5c99b9a66d8fa 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1073,12 +1073,8 @@ pulls.num_conflicting_files_1 = "%d conflicting file" pulls.num_conflicting_files_n = "%d conflicting files" pulls.approve_count_1 = "%d approval" pulls.approve_count_n = "%d approvals" -pulls.approve_non_official_count_1 = "+%d non-official" -pulls.approve_non_official_count_n = "+%d non-official" pulls.reject_count_1 = "%d change request" pulls.reject_count_n = "%d change requests" -pulls.reject_non_official_count_1 = "+%d non-official" -pulls.reject_non_official_count_n = "+%d non-official" pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled. pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually. diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 7e84b5c5db75b..e3d54b5baaef7 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -269,7 +269,7 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB assigneeID = 0 // Reset ID to prevent unexpected selection of assignee. } - ctx.Data["ApprovalCounts"] = func(issueID int64, typ string, official bool) int64 { + ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 { counts, ok := approvalCounts[issueID] if !ok || len(counts) == 0 { return 0 @@ -279,7 +279,7 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB reviewTyp = models.ReviewTypeReject } for _, count := range counts { - if count.Type == reviewTyp && count.Official == official { + if count.Type == reviewTyp { return count.Count } } diff --git a/routers/user/home.go b/routers/user/home.go index 66de3851089ba..f3566be94642b 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -583,7 +583,7 @@ func Issues(ctx *context.Context) { } ctx.Data["Issues"] = issues - ctx.Data["ApprovalCounts"] = func(issueID int64, typ string, official bool) int64 { + ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 { counts, ok := approvalCounts[issueID] if !ok || len(counts) == 0 { return 0 @@ -593,7 +593,7 @@ func Issues(ctx *context.Context) { reviewTyp = models.ReviewTypeReject } for _, count := range counts { - if count.Type == reviewTyp && count.Official == official { + if count.Type == reviewTyp { return count.Count } } diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 994bdaf3a52ca..1e5e1743babd6 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -269,18 +269,14 @@ {{end}} {{if .IsPull}} - {{$approveOfficial := call $approvalCounts .ID "approve" true}} - {{$approveNonOfficial := call $approvalCounts .ID "approve" false}} - {{$rejectOfficial := call $approvalCounts .ID "reject" true}} - {{$rejectNonOfficial := call $approvalCounts .ID "reject" false}} - {{if or (gt $approveOfficial 0) (gt $approveNonOfficial 0) (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} {{svg "octicon-check" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} - {{if gt $approveNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $approveNonOfficial "repo.pulls.approve_non_official_count_1" "repo.pulls.approve_non_official_count_n") $approveNonOfficial}}){{end}} - {{if or (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{if or (gt $rejectOfficial 0)}} {{svg "octicon-x" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} - {{if gt $rejectNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $rejectNonOfficial "repo.pulls.reject_non_official_count_1" "repo.pulls.reject_non_official_count_n") $rejectNonOfficial}}){{end}} {{end}} {{end}} {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index bdd5ea925f0ef..e53c5fd0356ea 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -153,18 +153,14 @@ {{end}} {{if .IsPull}} - {{$approveOfficial := call $approvalCounts .ID "approve" true}} - {{$approveNonOfficial := call $approvalCounts .ID "approve" false}} - {{$rejectOfficial := call $approvalCounts .ID "reject" true}} - {{$rejectNonOfficial := call $approvalCounts .ID "reject" false}} - {{if or (gt $approveOfficial 0) (gt $approveNonOfficial 0) (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0) }} {{svg "octicon-check" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} - {{if gt $approveNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $approveNonOfficial "repo.pulls.approve_non_official_count_1" "repo.pulls.approve_non_official_count_n") $approveNonOfficial}}){{end}} {{if or (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} {{svg "octicon-x" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} - {{if gt $rejectNonOfficial 0}}({{$.i18n.Tr (TrN $.i18n.Lang $rejectNonOfficial "repo.pulls.reject_non_official_count_1" "repo.pulls.reject_non_official_count_n") $rejectNonOfficial}}){{end}} {{end}} {{end}} {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} From 37251b95eea4d09ca37f982bb5908447d69b5957 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 29 Feb 2020 10:06:05 +0000 Subject: [PATCH 3/4] fixup --- templates/user/dashboard/issues.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index e53c5fd0356ea..81bfc3e46cbfb 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -158,7 +158,7 @@ {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0) }} {{svg "octicon-check" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} - {{if or (gt $rejectOfficial 0) (gt $rejectNonOfficial 0)}} + {{if or (gt $rejectOfficial 0)}} {{svg "octicon-x" 16}} {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} {{end}} From 7bce03489e5d9a6f80b1d20ddc65367198b4d427 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Mon, 2 Mar 2020 16:43:09 +0000 Subject: [PATCH 4/4] Add PR features to milestone_issues.tmpl --- templates/repo/issue/milestone_issues.tmpl | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 49712b1d09fdb..6d08df87dfb25 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -177,6 +177,7 @@
    + {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}} {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
  • @@ -185,9 +186,15 @@
  • {{end}} -
    #{{.Index}}
    +
    #{{.Index}}
    {{.Title}} + {{if .IsPull }} + {{if (index $.CommitStatus .PullRequest.ID)}} + {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}} + {{end}} + {{end}} + {{range .Labels}} {{.Name}} {{end}} @@ -201,11 +208,15 @@ {{end}}

    - {{if gt .Poster.ID 0}} - {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink (.Poster.GetDisplayName|Escape) | Safe}} + {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} + {{if .OriginalAuthor }} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor | Safe}} + {{else if gt .Poster.ID 0}} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink (.Poster.GetDisplayName | Escape) | Safe}} {{else}} - {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName|Escape) | Safe}} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} + {{if .Ref}} {{svg "octicon-git-branch" 16}} {{.Ref}} @@ -227,6 +238,21 @@ {{end}} + {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if or (gt $rejectOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{end}} + {{end}} + {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} + {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} + {{end}} + {{end}}

    {{end}}