Skip to content

Commit

Permalink
feat: bigger merge status
Browse files Browse the repository at this point in the history
  • Loading branch information
dlvhdr committed Feb 22, 2025
1 parent 1abd85b commit 400a01e
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 168 deletions.
26 changes: 13 additions & 13 deletions data/prapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ type PullRequestData struct {
Author struct {
Login string
}
AuthorAssociation string
UpdatedAt time.Time
CreatedAt time.Time
Url string
State string
Mergeable string
ReviewDecision string
Additions int
Deletions int
HeadRefName string
BaseRefName string
HeadRepository struct {
AuthorAssociation string
UpdatedAt time.Time
CreatedAt time.Time
Url string
State string
Mergeable string
ReviewDecision string
Additions int
Deletions int
HeadRefName string
BaseRefName string
HeadRepository struct {
Name string
}
HeadRef struct {
Expand All @@ -43,7 +43,7 @@ type PullRequestData struct {
Repository Repository
Assignees Assignees `graphql:"assignees(first: 3)"`
Comments Comments `graphql:"comments(last: 5, orderBy: { field: UPDATED_AT, direction: DESC })"`
LatestReviews Reviews `graphql:"latestReviews(last: 3)"`
Reviews Reviews `graphql:"reviews(last: 3)"`
ReviewThreads ReviewThreads `graphql:"reviewThreads(last: 20)"`
ReviewRequests ReviewRequests `graphql:"reviewRequests(last: 10)"`
IsDraft bool
Expand Down
20 changes: 17 additions & 3 deletions data/repository.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
package data

import (
graphql "github.com/cli/shurcooL-graphql"
)

type BranchProtectionRules struct {
Nodes []struct {
RequiredApprovingReviewCount int
RequiresApprovingReviews graphql.Boolean
RequiresCodeOwnerReviews graphql.Boolean
RequiresStatusChecks graphql.Boolean
}
}

type Repository struct {
Name string
NameWithOwner string
IsArchived bool
Name string
NameWithOwner string
IsArchived bool
BranchProtectionRules BranchProtectionRules `graphql:"branchProtectionRules(first: 1)"`
}
13 changes: 7 additions & 6 deletions data/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@ type RowData interface {
GetUpdatedAt() time.Time
}

func IsStatusSkipped(status string) bool {
func IsStatusWaiting(status string) bool {
return status == "PENDING" ||
status == "QUEUED" ||
status == "IN_PROGRESS" ||
status == "WAITING"
}

func IsStatusWaiting(status string) bool {
return status == "PENDING" ||
status == "QUEUED" ||
status == "IN_PROGRESS" ||
status == "WAITING"
func IsConclusionASkip(conclusion string) bool {
return conclusion == "SKIPPED"
}

func IsConclusionAFailure(conclusion string) bool {
return conclusion == "FAILURE" || conclusion == "TIMED_OUT" || conclusion == "STARTUP_FAILURE"
}

func IsConclusionASuccess(conclusion string) bool {
return conclusion == "SUCCESS"
}

func GetAuthorRoleIcon(role string, theme theme.Theme) string {
// https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
switch role {
Expand Down
179 changes: 159 additions & 20 deletions imposters/pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@
"mergeStateStatus": "CLEAN"
},
{
"number": 2505,
"title": "feat(nvim): add snacks.nvim",
"number": 2504,
"title": "feat(nvim): all green",
"body": "",
"author": {
"login": "dlvhdr"
Expand All @@ -366,7 +366,7 @@
"url": "https://github.com/dlvhdr/dotfiles/pull/1",
"state": "OPEN",
"mergeable": "MERGEABLE",
"reviewDecision": "REVIEW_REQUIRED",
"reviewDecision": "APPROVED",
"additions": 120,
"deletions": 58,
"headRefName": "master",
Expand All @@ -389,17 +389,9 @@
"nodes": [],
"totalCount": 0
},
"reviewRequests": {
"totalCount": 1,
"nodes": [
{
"asCodeOwner": true
}
]
},
"latestReviews": {
"totalCount": 0,
"nodes": []
"totalCount": 1,
"nodes": [{ "state": "APPROVED" }]
},
"reviewThreads": {
"nodes": []
Expand All @@ -419,7 +411,8 @@
{
"__typename": "CheckRun",
"name": "CodeQL",
"status": "IN_PROGRESS",
"status": "COMPLETED",
"conclusion": "SUCCESS",
"checkSuite": {
"creator": {
"login": ""
Expand All @@ -430,12 +423,85 @@
}
}
}
},
}
]
}
}
}
}
]
},
"labels": {
"nodes": []
},
"mergeStateStatus": "CLEAN"
},
{
"number": 2505,
"title": "feat(nvim): waiting",
"body": "",
"author": {
"login": "dlvhdr"
},
"updatedAt": "2025-01-19T11:42:47Z",
"createdAt": "2025-01-18T11:42:47Z",
"url": "https://github.com/dlvhdr/dotfiles/pull/1",
"state": "OPEN",
"mergeable": "MERGEABLE",
"reviewDecision": "REVIEW_REQUIRED",
"additions": 120,
"deletions": 58,
"headRefName": "master",
"baseRefName": "master",
"headRepository": {
"name": "dotfiles"
},
"headRef": {
"name": "master"
},
"repository": {
"name": "dotfiles",
"nameWithOwner": "dlvhdr/dotfiles",
"isArchived": false
},
"assignees": {
"nodes": []
},
"comments": {
"nodes": [],
"totalCount": 0
},
"reviewRequests": {
"totalCount": 1,
"nodes": [
{
"asCodeOwner": false
}
]
},
"latestReviews": {
"totalCount": 0,
"nodes": []
},
"reviewThreads": {
"nodes": []
},
"isDraft": false,
"commits": {
"nodes": [
{
"commit": {
"deployments": {
"nodes": []
},
"statusCheckRollup": {
"contexts": {
"totalCount": 3,
"nodes": [
{
"__typename": "CheckRun",
"name": "CodeQL",
"status": "COMPLETED",
"conclusion": "SUCCESS",
"status": "IN_PROGRESS",
"checkSuite": {
"creator": {
"login": ""
Expand All @@ -446,12 +512,85 @@
}
}
}
},
}
]
}
}
}
}
]
},
"labels": {
"nodes": []
},
"mergeStateStatus": "CLEAN"
},
{
"number": 2505,
"title": "feat(nvim): waiting on code owner",
"body": "",
"author": {
"login": "dlvhdr"
},
"updatedAt": "2025-01-19T11:42:47Z",
"createdAt": "2025-01-18T11:42:47Z",
"url": "https://github.com/dlvhdr/dotfiles/pull/1",
"state": "OPEN",
"mergeable": "MERGEABLE",
"reviewDecision": "REVIEW_REQUIRED",
"additions": 120,
"deletions": 58,
"headRefName": "master",
"baseRefName": "master",
"headRepository": {
"name": "dotfiles"
},
"headRef": {
"name": "master"
},
"repository": {
"name": "dotfiles",
"nameWithOwner": "dlvhdr/dotfiles",
"isArchived": false
},
"assignees": {
"nodes": []
},
"comments": {
"nodes": [],
"totalCount": 0
},
"reviewRequests": {
"totalCount": 1,
"nodes": [
{
"asCodeOwner": true
}
]
},
"latestReviews": {
"totalCount": 0,
"nodes": []
},
"reviewThreads": {
"nodes": []
},
"isDraft": false,
"commits": {
"nodes": [
{
"commit": {
"deployments": {
"nodes": []
},
"statusCheckRollup": {
"contexts": {
"totalCount": 3,
"nodes": [
{
"__typename": "CheckRun",
"name": "CodeQL",
"status": "COMPLETED",
"conclusion": "SUCCESS",
"status": "IN_PROGRESS",
"checkSuite": {
"creator": {
"login": ""
Expand Down
4 changes: 4 additions & 0 deletions ui/common/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type CommonStyles struct {
MainTextStyle lipgloss.Style
FooterStyle lipgloss.Style
ErrorStyle lipgloss.Style
DraftGlyph string
WaitingGlyph string
FailureGlyph string
SuccessGlyph string
Expand Down Expand Up @@ -57,6 +58,9 @@ func BuildStyles(theme theme.Theme) CommonStyles {
s.CommentGlyph = lipgloss.NewStyle().
Foreground(theme.PrimaryText).
Render(constants.CommentIcon)
s.DraftGlyph = lipgloss.NewStyle().
Foreground(theme.PrimaryText).
Render(constants.DraftIcon)

return s
}
2 changes: 1 addition & 1 deletion ui/components/pr/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (pr *PullRequest) renderReviewStatus() string {
return reviewCellStyle.Render("")
}

if pr.Data.LatestReviews.TotalCount > 0 {
if pr.Data.Reviews.TotalCount > 0 {
return reviewCellStyle.Render(pr.Ctx.Styles.Common.CommentGlyph)
}

Expand Down
2 changes: 1 addition & 1 deletion ui/components/prsidebar/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (m *Model) renderActivity() string {
})
}

for _, review := range m.pr.Data.LatestReviews.Nodes {
for _, review := range m.pr.Data.Reviews.Nodes {
renderedReview, err := m.renderReview(review, markdownRenderer)
if err != nil {
continue
Expand Down
Loading

0 comments on commit 400a01e

Please sign in to comment.