Skip to content

Commit db14702

Browse files
authored
display pull request result #6 (#7)
display result on quickfix list
1 parent eae0cc5 commit db14702

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

lua/telescope/_extensions/gh_actions.lua

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,46 @@ A.gh_pr_checkout = function(prompt_bufnr)
1212
if vim.tbl_isempty(tmp_table) then
1313
return
1414
end
15+
16+
local qf_entry = {{
17+
text="Checking out pull request #" .. tmp_table[1] ..", please wait ..."
18+
}}
19+
20+
local on_output = function(_, line)
21+
table.insert(qf_entry,{
22+
text = line
23+
})
24+
pcall(vim.schedule_wrap( function()
25+
vim.fn.setqflist(qf_entry,"r")
26+
end))
27+
end
28+
1529
local job = Job:new({
1630
enable_recording = true ,
1731
command = "gh",
18-
args = {"pr", "checkout" ,tmp_table[1]}
32+
args = {"pr", "checkout" ,tmp_table[1]},
33+
on_stdout = on_output,
34+
on_stderr = on_output,
35+
36+
on_exit = function(_,status)
37+
if status == 0 then
38+
pcall(vim.schedule_wrap( function()
39+
vim.cmd[[cclose]]
40+
end))
41+
print("Pull request completed")
42+
end
43+
end,
1944
})
20-
-- need to display result in quickfix
21-
job:sync()
45+
46+
vim.fn.setqflist(qf_entry,"r")
47+
vim.cmd[[copen]]
48+
local timer = vim.loop.new_timer()
49+
timer:start(200, 0, vim.schedule_wrap(function()
50+
-- increase timeout to 10000ms and wait interval to 20
51+
-- default value is 5000ms and 10
52+
job:sync(10000,20)
53+
end))
54+
2255
end
2356

2457

0 commit comments

Comments
 (0)