Skip to content

Commit

Permalink
Add gh issues develop #ID --checkout
Browse files Browse the repository at this point in the history
This adds the only recently available Github CLI command
to create a branch for an issue and checking it locally out.

See cli/cli#5469
  • Loading branch information
peterfication committed Feb 28, 2023
1 parent ee95c50 commit 795d318
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lua/telescope/_extensions/gh_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ A.gh_web_view = function(type)
end
end

A.gh_develop = function()
return function(prompt_bufnr)
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
local tmp_table = vim.split(selection.value, "\t")
if vim.tbl_isempty(tmp_table) then
return
end
local id = tmp_table[1]
-- We can't use os.execute here because it takes a bit
vim.fn.jobstart(
"echo \"Creating a new branch ...\" && gh issue develop " .. id .. " --checkout && echo \"Done!\"",
{
on_stdout = function(_channel_id, data, _name)
if data[1] ~= "" then
print(data[1])
end
end
}
)
end
end

A.gh_gist_append = function(prompt_bufnr)
local selection = action_state.get_selected_entry()
actions.close(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-z>", gh_a.gh_develop "issue")
return true
end,
}):find()
Expand Down

0 comments on commit 795d318

Please sign in to comment.