Skip to content

Commit

Permalink
display combined status of checks for pr
Browse files Browse the repository at this point in the history
  • Loading branch information
macovsky committed Nov 2, 2024
1 parent f09ff94 commit 801365e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/octo/gh/graphql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,9 @@ query($endCursor: String) {
}
}
}
statusCheckRollup {
state
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions lua/octo/ui/writers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,15 @@ function M.write_details(bufnr, issue, update)
table.insert(details, decision_vt)
end

if issue.statusCheckRollup and issue.statusCheckRollup ~= vim.NIL then
local state = issue.statusCheckRollup.state
local checks_vt = {
{ "Checks: ", "OctoDetailsLabel" },
{ utils.checks_icon_map[state] .. utils.checks_message_map[state], utils.checks_hl_map[state] },
}
table.insert(details, checks_vt)
end

-- changes
local changes_vt = {
{ "Commits: ", "OctoDetailsLabel" },
Expand Down
24 changes: 24 additions & 0 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ M.file_status_map = {
renamed = "R",
}

M.checks_hl_map = {
ERROR = "OctoStateDismissed",
EXPECTED = "OctoStatePending",
FAILURE = "OctoStateDismissed",
PENDING = "OctoStatePending",
SUCCESS = "OctoStateApproved",
}

M.checks_icon_map = {
ERROR = "× ",
EXPECTED = "",
FAILURE = "× ",
PENDING = "",
SUCCESS = "",
}

M.checks_message_map = {
ERROR = "errored",
EXPECTED = "expected",
FAILURE = "failed",
PENDING = "pending",
SUCCESS = "passed",
}

function M.trim(str)
if type(vim.fn.trim) == "function" then
return vim.fn.trim(str)
Expand Down

0 comments on commit 801365e

Please sign in to comment.