Skip to content

Commit

Permalink
consolidate with previous checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wd60622 committed Jan 15, 2025
1 parent b8ab3d2 commit d093db7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
16 changes: 5 additions & 11 deletions lua/octo/ui/writers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,11 @@ function M.write_details(bufnr, issue, update)
-- checks
if issue.statusCheckRollup and issue.statusCheckRollup ~= vim.NIL then
local state = issue.statusCheckRollup.state
local state_info = utils.state_map[state]
local message = state_info.symbol .. state
local checks_vt = {
{ "Checks: ", "OctoDetailsLabel" },
{ utils.checks_message_map[state], utils.checks_hl_map[state] },
{ message, state_info.hl },
}
table.insert(details, checks_vt)
end
Expand Down Expand Up @@ -1323,17 +1325,9 @@ local get_status_check = function(statusCheckRollup)
end

local state = statusCheckRollup.state
local state_info = utils.state_map[state]

-- https://docs.github.com/en/graphql/reference/enums#statusstate
local mapping = {
SUCCESS = { "", "OctoGreen" },
EXPECTED = { "", "OctoGreen" },
FAILURE = { "", "OctoRed" },
ERROR = { "", "OctoRed" },
PENDING = { "", "OctoYellow" },
}

return mapping[state]
return { state_info.symbol, state_info.hl }
end

function M.write_commit_event(bufnr, item)
Expand Down
20 changes: 6 additions & 14 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,12 @@ M.file_status_map = {
renamed = "R",
}

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

M.checks_message_map = {
ERROR = "× ERRORED",
EXPECTED = " EXPECTED",
FAILURE = "× FAILED",
PENDING = " PENDING",
SUCCESS = "✓ PASSED",
M.state_map = {
ERROR = { symbol = "× ", hl = "OctoStateDismissed" },
FAILURE = { symbol = "× ", hl = "OctoStateDismissed" },
EXPECTED = { symbol = "", hl = "OctoStatePending" },
PENDING = { symbol = "", hl = "OctoStatePending" },
SUCCESS = { symbol = "", hl = "OctoStateApproved" },
}

M.mergeable_hl_map = {
Expand Down

0 comments on commit d093db7

Please sign in to comment.