Skip to content

Commit

Permalink
improv(github): use separate icon for draftPR
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jul 21, 2024
1 parent c3eb2a9 commit 4910303
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ require("tinygit").setup({
notPlannedIssue = "",
openPR = "🟩",
mergedPR = "🟪",
draftPR = "",
closedPR = "🟥",
},
statusline = {
Expand Down
34 changes: 18 additions & 16 deletions lua/tinygit/commands/github.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,25 @@ end
---@param issue table
---@return string
local function issueListFormatter(issue)
local isPR = issue.pull_request ~= nil
local merged = isPR and issue.pull_request.merged_at ~= nil
local reason = issue.state_reason

local icon
if issue.state == "open" and isPR then
icon = config.issueIcons.openPR
elseif issue.state == "closed" and isPR and merged then
icon = config.issueIcons.mergedPR
elseif issue.state == "closed" and isPR and not merged then
icon = config.issueIcons.closedPR
elseif issue.state == "closed" and reason == "completed" then
icon = config.issueIcons.closedIssue
elseif issue.state == "closed" and reason == "not_planned" then
icon = config.issueIcons.notPlannedIssue
elseif issue.state == "open" and not isPR then
icon = config.issueIcons.openIssue
if issue.pull_request then
if issue.draft then
icon = config.issueIcons.draftPR
elseif issue.state == "open" then
icon = config.issueIcons.openPR
elseif issue.pull_request.merged_at then
icon = config.issueIcons.mergedPR
else
icon = config.issueIcons.closedPR
end
else
if issue.state == "open" then
icon = config.issueIcons.openIssue
elseif issue.state_reason == "completed" then
icon = config.issueIcons.closedIssue
elseif issue.state_reason == "not_planned" then
icon = config.issueIcons.notPlannedIssue
end
end

return ("%s #%s %s by %s"):format(icon, issue.number, issue.title, issue.user.login)
Expand Down
2 changes: 2 additions & 0 deletions lua/tinygit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local M = {}
---@field openPR string
---@field mergedPR string
---@field closedPR string
---@field draftPR string

---@class commitConfig
---@field conventionalCommits {enforce: boolean, keywords: string[]}
Expand Down Expand Up @@ -103,6 +104,7 @@ local defaultConfig = {
notPlannedIssue = "",
openPR = "🟩",
mergedPR = "🟪",
draftPR = "",
closedPR = "🟥",
},
statusline = {
Expand Down

0 comments on commit 4910303

Please sign in to comment.