Skip to content

Commit

Permalink
Merge branch 'master' into 608-empty-content-in-diff-buffer-when-tryi…
Browse files Browse the repository at this point in the history
…ng-to-fetch-from-commit-at-random-times-1
  • Loading branch information
wd60622 authored Dec 12, 2024
2 parents 03fa8b6 + dfb292d commit 7beec85
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function M.setup()
local buffer = octo_buffers[bufnr]

if buffer and buffer.kind and buffer.kind == "issue" then
utils.develop_issue(buffer.node.number)
utils.develop_issue(buffer.repo, buffer.node.number, repo)
else
local opts = M.process_varargs(repo, ...)
picker.issues(opts, true)
Expand Down
16 changes: 8 additions & 8 deletions lua/octo/pickers/telescope/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,10 @@ local function develop_issue(prompt_bufnr, type)
local selection = action_state.get_selected_entry(prompt_bufnr)
actions.close(prompt_bufnr)

utils.develop_issue(selection.obj.number)
utils.develop_issue(selection.repo, selection.obj.number, nil)
end

function M.issues(opts, develop)
local replace
if develop then
replace = develop_issue
else
replace = open_issue_buffer
end

opts = opts or {}
if not opts.states then
opts.states = "OPEN"
Expand All @@ -157,6 +150,13 @@ function M.issues(opts, develop)
return
end

local replace
if develop then
replace = develop_issue
else
replace = open_issue_buffer
end

local owner, name = utils.split_repo(opts.repo)
local cfg = octo_config.values
local order_by = cfg.issues.order_by
Expand Down
30 changes: 25 additions & 5 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,38 @@ function M.commit_exists(commit, cb)
}):start()
end

function M.develop_issue(issue_number)
function M.develop_issue(issue_repo, issue_number, branch_repo)
if not Job then
return
end

if M.is_blank(branch_repo) then
branch_repo = M.get_remote_name()
end

Job:new({
enable_recording = true,
command = "gh",
args = { "issue", "develop", issue_number, "--checkout" },
on_exit = vim.schedule_wrap(function()
local output = vim.fn.system "git branch --show-current"
M.info("Switched to " .. output)
args = {
"issue",
"develop",
"--repo",
issue_repo,
issue_number,
"--checkout",
"--branch-repo",
branch_repo,
},
on_exit = vim.schedule_wrap(function(job, code)
if code == 0 then
local output = vim.fn.system "git branch --show-current"
M.info("Switched to " .. output)
else
local stderr = table.concat(job:stderr_result(), "\n")
if not M.is_blank(stderr) then
M.error(stderr)
end
end
end),
}):start()
end
Expand Down

0 comments on commit 7beec85

Please sign in to comment.