Skip to content

Commit a4e84b4

Browse files
committed
refactor: Make gh_qf_action issue/pr generic
1 parent ee95c50 commit a4e84b4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lua/telescope/_extensions/gh_actions.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ local function close_telescope_prompt(prompt_bufnr)
1616
end
1717
return tmp_table[1]
1818
end
19-
local function gh_qf_action(pr_number, action, msg)
20-
if pr_number == nil then
19+
local function gh_qf_action(number, action, msg)
20+
if number == nil then
2121
return
2222
end
2323

2424
local qf_entry = { {
25-
text = msg .. pr_number .. ", please wait ...",
25+
text = msg .. number .. ", please wait ...",
2626
} }
2727

2828
local on_output = function(_, line)
@@ -36,7 +36,7 @@ local function gh_qf_action(pr_number, action, msg)
3636
local job = Job:new {
3737
enable_recording = true,
3838
command = "gh",
39-
args = flatten { "pr", action, pr_number },
39+
args = flatten { action, number },
4040
on_stdout = on_output,
4141
on_stderr = on_output,
4242

@@ -45,7 +45,7 @@ local function gh_qf_action(pr_number, action, msg)
4545
pcall(vim.schedule_wrap(function()
4646
vim.cmd [[cclose]]
4747
end))
48-
print "Pull request completed"
48+
print "GH action completed"
4949
end
5050
end,
5151
}
@@ -94,7 +94,7 @@ end
9494

9595
A.gh_pr_checkout = function(prompt_bufnr)
9696
local pr_number = close_telescope_prompt(prompt_bufnr)
97-
gh_qf_action(pr_number, "checkout", "Checking out pull request #")
97+
gh_qf_action(pr_number, { "pr", "checkout" }, "Checking out pull request #")
9898
end
9999

100100
A.gh_web_view = function(type)
@@ -227,13 +227,13 @@ A.gh_pr_merge = function(prompt_bufnr)
227227
action = "-s"
228228
end
229229
if action ~= nil then
230-
gh_qf_action(pr_number, { "merge", action }, "Merge pull request #")
230+
gh_qf_action(pr_number, { "pr", "merge", action }, "Merge pull request #")
231231
end
232232
end
233233

234234
A.gh_pr_approve = function(prompt_bufnr)
235235
local pr_number = close_telescope_prompt(prompt_bufnr)
236-
gh_qf_action(pr_number, { "review", "--approve" }, "Approve pull request #")
236+
gh_qf_action(pr_number, { "pr", "review", "--approve" }, "Approve pull request #")
237237
end
238238

239239
A.gh_run_web_view = function(prompt_bufnr)

0 commit comments

Comments
 (0)