-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show approvals on the PR listing page #8762
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,8 +232,15 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB | |
ctx.ServerError("LoadPullRequest", err) | ||
return | ||
} | ||
pull := issues[i].PullRequest | ||
|
||
commitStatus[issues[i].PullRequest.ID], _ = issues[i].PullRequest.GetLastCommitStatus() | ||
if err := pull.LoadProtectedBranch(); err == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're not handling the error here. Please do something like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aah ok, is there a subtle difference in the behaviour of errors and nil? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the function returns In Go, there is this pattern of keeping a "happy path" of code, that's why you'll see a lot of |
||
if pull.ProtectedBranch != nil && pull.ProtectedBranch.RequiredApprovals != 0 { | ||
pull.ProtectedBranch.GrantedApprovalsCount = pull.ProtectedBranch.GetGrantedApprovalsCount(pull) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set value in slice also when branch is not protected? (with 0 value) |
||
|
||
commitStatus[pull.ID], _ = pull.GetLastCommitStatus() | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -222,6 +222,14 @@ | |||||
<a class="ui label has-emoji" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a> | ||||||
{{end}} | ||||||
|
||||||
{{if .IsPull}} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be reduced to one
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aah that's much simpler, will do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this didn't work for branches without protection enabled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose that requires that $.RequiredApprovals contain all indexes? Should be possible by setting them 0 in issue.go. |
||||||
{{if .PullRequest.ProtectedBranch}} | ||||||
{{if .PullRequest.ProtectedBranch.RequiredApprovals}} | ||||||
<span class="comment ui right"><i class="octicon octicon-eye"></i> {{.PullRequest.ProtectedBranch.GrantedApprovalsCount}} / {{.PullRequest.ProtectedBranch.RequiredApprovals}}</span> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Continue things .. from abouth |
||||||
{{end}} | ||||||
{{end}} | ||||||
{{end}} | ||||||
|
||||||
{{if .NumComments}} | ||||||
<span class="comment ui right"><i class="octicon octicon-comment"></i> {{.NumComments}}</span> | ||||||
{{end}} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be added column so database so should be marked so:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
granted aprovals Should be stored for each PR and not for each branch?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the information Iis stored already somewhere ... have to check where ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah, so any properties I add are mapped to the database by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can get the information via
models.GetUniqueApprovalsByPullRequestID(prID int64) ([]*Review, error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
summary:
ctx.Data["GrantedApprovalsCount"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would I reference that per PR, seeing as I have an array of them? Issues get popped under
ctx.Data["Issues"]
as a whole so I created a property to be able to access it from each one within the template. I presume something dynamic likectx.Data["Issues"][i].GrantedApprovals = count
isn't possible - I come from a JS background 😉.The reason I left it as a property of
ProtectedBranch
was simply becauseGetGrantedApprovalsCount
lived there already, and I just assumed I would keep them together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can look into it later ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm attempting to change it to a solution similar to
ctx.Data["CommitStatus"]
and removing the extra property onProtectedBranch
.Looking at it,
GetUniqueApprovalsByPullRequestID
will return all approved reviews for a given PR, not just those on the approval whitelist. This might be equally valid - what would the user reasonably expect to see? Personally I think only reviews "which matter" should count to quickly determine if a PR is ready to be merged.