Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lua/telescope/_extensions/gh_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ local function close_telescope_prompt(prompt_bufnr)
end
return tmp_table[1]
end
local function gh_qf_action(pr_number, action, msg)
if pr_number == nil then
local function gh_qf_action(number, action, msg)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored slightly so that it can work with both issues and PR's

if number == nil then
return
end

local qf_entry = { {
text = msg .. pr_number .. ", please wait ...",
text = msg .. number .. ", please wait ...",
} }

local on_output = function(_, line)
Expand All @@ -36,7 +36,7 @@ local function gh_qf_action(pr_number, action, msg)
local job = Job:new {
enable_recording = true,
command = "gh",
args = flatten { "pr", action, pr_number },
args = flatten { action, number },
on_stdout = on_output,
on_stderr = on_output,

Expand All @@ -45,7 +45,7 @@ local function gh_qf_action(pr_number, action, msg)
pcall(vim.schedule_wrap(function()
vim.cmd [[cclose]]
end))
print "Pull request completed"
print "GH action completed"
end
end,
}
Expand Down Expand Up @@ -92,9 +92,14 @@ A.gh_issue_insert_markdown_link = function(prompt_bufnr)
end
end

A.gh_issue_develop = function(prompt_bufnr)
local issue_number = close_telescope_prompt(prompt_bufnr)
gh_qf_action(issue_number, { "issue", "develop", "--checkout" }, "Checking out issue #")
end

A.gh_pr_checkout = function(prompt_bufnr)
local pr_number = close_telescope_prompt(prompt_bufnr)
gh_qf_action(pr_number, "checkout", "Checking out pull request #")
gh_qf_action(pr_number, { "pr", "checkout" }, "Checking out pull request #")
end

A.gh_web_view = function(type)
Expand Down Expand Up @@ -227,13 +232,13 @@ A.gh_pr_merge = function(prompt_bufnr)
action = "-s"
end
if action ~= nil then
gh_qf_action(pr_number, { "merge", action }, "Merge pull request #")
gh_qf_action(pr_number, { "pr", "merge", action }, "Merge pull request #")
end
end

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

A.gh_run_web_view = function(prompt_bufnr)
Expand Down
1 change: 1 addition & 0 deletions lua/telescope/_extensions/gh_builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ B.gh_issues = function(opts)
actions.select_default:replace(gh_a.gh_issue_insert)
map("i", "<c-t>", gh_a.gh_web_view "issue")
map("i", "<c-l>", gh_a.gh_issue_insert_markdown_link)
map("i", "<c-b>", gh_a.gh_issue_develop)
return true
end,
}):find()
Expand Down