Base changes for PR project items
This commit is contained in:
parent
7851c9c664
commit
72f5fbbec0
2 changed files with 18 additions and 5 deletions
|
|
@ -150,8 +150,9 @@ func ProjectsV2ItemsForPullRequest(client *Client, repo ghrepo.Interface, pr *Pu
|
|||
Repository struct {
|
||||
PullRequest struct {
|
||||
ProjectItems struct {
|
||||
Nodes []*projectV2Item
|
||||
PageInfo struct {
|
||||
TotalCount int
|
||||
Nodes []*projectV2Item
|
||||
PageInfo struct {
|
||||
HasNextPage bool
|
||||
EndCursor string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ var defaultFields = []string{
|
|||
"url", "number", "title", "state", "body", "author", "autoMergeRequest",
|
||||
"isDraft", "maintainerCanModify", "mergeable", "additions", "deletions", "commitsCount",
|
||||
"baseRefName", "headRefName", "headRepositoryOwner", "headRepository", "isCrossRepository",
|
||||
"reviewRequests", "reviews", "assignees", "labels", "projectCards", "milestone",
|
||||
"reviewRequests", "reviews", "assignees", "labels", "projectCards", "projectItems", "milestone",
|
||||
"comments", "reactionGroups", "createdAt", "statusCheckRollup",
|
||||
}
|
||||
|
||||
|
|
@ -439,11 +439,23 @@ func prLabelList(pr api.PullRequest, cs *iostreams.ColorScheme) string {
|
|||
}
|
||||
|
||||
func prProjectList(pr api.PullRequest) string {
|
||||
if len(pr.ProjectCards.Nodes) == 0 {
|
||||
totalCount := pr.ProjectCards.TotalCount + pr.ProjectItems.TotalCount
|
||||
count := len(pr.ProjectCards.Nodes) + len(pr.ProjectItems.Nodes)
|
||||
|
||||
if count == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
projectNames := make([]string, 0, len(pr.ProjectCards.Nodes))
|
||||
|
||||
for _, project := range pr.ProjectItems.Nodes {
|
||||
colName := project.Status.Name
|
||||
if colName == "" {
|
||||
colName = "No Status"
|
||||
}
|
||||
projectNames = append(projectNames, fmt.Sprintf("%s (%s)", project.Project.Title, colName))
|
||||
}
|
||||
|
||||
for _, project := range pr.ProjectCards.Nodes {
|
||||
if project == nil {
|
||||
continue
|
||||
|
|
@ -456,7 +468,7 @@ func prProjectList(pr api.PullRequest) string {
|
|||
}
|
||||
|
||||
list := strings.Join(projectNames, ", ")
|
||||
if pr.ProjectCards.TotalCount > len(pr.ProjectCards.Nodes) {
|
||||
if totalCount > count {
|
||||
list += ", …"
|
||||
}
|
||||
return list
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue