Skip to content

Commit 795d318

Browse files
committed
Add gh issues develop #ID --checkout
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
1 parent ee95c50 commit 795d318

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lua/telescope/_extensions/gh_actions.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,29 @@ A.gh_web_view = function(type)
115115
end
116116
end
117117

118+
A.gh_develop = function()
119+
return function(prompt_bufnr)
120+
local selection = action_state.get_selected_entry()
121+
actions.close(prompt_bufnr)
122+
local tmp_table = vim.split(selection.value, "\t")
123+
if vim.tbl_isempty(tmp_table) then
124+
return
125+
end
126+
local id = tmp_table[1]
127+
-- We can't use os.execute here because it takes a bit
128+
vim.fn.jobstart(
129+
"echo \"Creating a new branch ...\" && gh issue develop " .. id .. " --checkout && echo \"Done!\"",
130+
{
131+
on_stdout = function(_channel_id, data, _name)
132+
if data[1] ~= "" then
133+
print(data[1])
134+
end
135+
end
136+
}
137+
)
138+
end
139+
end
140+
118141
A.gh_gist_append = function(prompt_bufnr)
119142
local selection = action_state.get_selected_entry()
120143
actions.close(prompt_bufnr)

lua/telescope/_extensions/gh_builtin.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ B.gh_issues = function(opts)
111111
actions.select_default:replace(gh_a.gh_issue_insert)
112112
map("i", "<c-t>", gh_a.gh_web_view "issue")
113113
map("i", "<c-l>", gh_a.gh_issue_insert_markdown_link)
114+
map("i", "<c-z>", gh_a.gh_develop "issue")
114115
return true
115116
end,
116117
}):find()

0 commit comments

Comments
 (0)