mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 01:48:30 +02:00
Pull DetailView: Show more pull informations (#271)
Pull Detailview: add head/base-branch, reviews, mergable info print info if reviews can not be loaded No Conflicts Reviewed-on: https://gitea.com/gitea/tea/pulls/271 Reviewed-by: Norwin <noerw@noreply.gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-Authored-By: 6543 <6543@obermui.de> Co-Committed-By: 6543 <6543@obermui.de>
This commit is contained in:
@ -13,7 +13,7 @@ import (
|
||||
// IssueDetails print an issue rendered to stdout
|
||||
func IssueDetails(issue *gitea.Issue) {
|
||||
OutputMarkdown(fmt.Sprintf(
|
||||
"# #%d %s (%s)\n%s created %s\n\n%s\n",
|
||||
"# #%d %s (%s)\n@%s created %s\n\n%s\n",
|
||||
issue.Index,
|
||||
issue.Title,
|
||||
issue.State,
|
||||
|
@ -11,14 +11,48 @@ import (
|
||||
)
|
||||
|
||||
// PullDetails print an pull rendered to stdout
|
||||
func PullDetails(pr *gitea.PullRequest) {
|
||||
OutputMarkdown(fmt.Sprintf(
|
||||
"# #%d %s (%s)\n%s created %s\n\n%s\n",
|
||||
func PullDetails(pr *gitea.PullRequest, reviews []*gitea.PullReview) {
|
||||
base := pr.Base.Name
|
||||
head := pr.Head.Name
|
||||
if pr.Head.RepoID != pr.Base.RepoID {
|
||||
if pr.Head.Repository != nil {
|
||||
head = pr.Head.Repository.Owner.UserName + ":" + head
|
||||
} else {
|
||||
head = "delete:" + head
|
||||
}
|
||||
}
|
||||
|
||||
out := fmt.Sprintf(
|
||||
"# #%d %s (%s)\n@%s created %s\t**%s** <- **%s**\n\n%s\n",
|
||||
pr.Index,
|
||||
pr.Title,
|
||||
pr.State,
|
||||
pr.Poster.UserName,
|
||||
FormatTime(*pr.Created),
|
||||
base,
|
||||
head,
|
||||
pr.Body,
|
||||
))
|
||||
)
|
||||
|
||||
if len(reviews) != 0 {
|
||||
out += "\n"
|
||||
revMap := make(map[string]gitea.ReviewStateType)
|
||||
for _, review := range reviews {
|
||||
switch review.State {
|
||||
case gitea.ReviewStateApproved,
|
||||
gitea.ReviewStateRequestChanges,
|
||||
gitea.ReviewStateRequestReview:
|
||||
revMap[review.Reviewer.UserName] = review.State
|
||||
}
|
||||
}
|
||||
for k, v := range revMap {
|
||||
out += fmt.Sprintf("\n @%s: %s", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
if pr.State == gitea.StateOpen && pr.Mergeable {
|
||||
out += "\nNo Conflicts"
|
||||
}
|
||||
|
||||
OutputMarkdown(out)
|
||||
}
|
||||
|
Reference in New Issue
Block a user