Skip to content

Commit

Permalink
Merge branch 'master' into refactor-search
Browse files Browse the repository at this point in the history
  • Loading branch information
wd60622 authored Mar 2, 2025
2 parents 20f1ac0 + ad15e6f commit 4f91b27
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| | reload | Reload PR. Same as doing `e!` |
| | browser | Open current PR in the browser |
| | url | Copies the URL of the current PR to the system clipboard |
| | runs | List all workflow runs for the PR |
| repo | list (3) | List repos user owns, contributes or belong to |
| | fork | Fork repo |
| | browser | Open current repo in the browser |
Expand Down
1 change: 1 addition & 0 deletions doc/octo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ See |octo-command-examples| for examples.
browser Open current PR in the browser.
url Copies the URL of the currently opened PR to the
system clipboard.
runs Show all workflow runs for the PR.


:Octo discussion [action] {args} *octo-commands-discussion*
Expand Down
10 changes: 10 additions & 0 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ function M.setup()
edit = function(...)
utils.get_pull_request(...)
end,
runs = function()
local buffer = get_current_buffer()
if not buffer or not buffer:isPullRequest() then
utils.error "Not a pull request buffer"
return
end
local headRefName = buffer.node.headRefName

require("octo.workflow_runs").list { branch = headRefName }
end,
close = function()
M.change_state "CLOSED"
end,
Expand Down
18 changes: 14 additions & 4 deletions lua/octo/workflow_runs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,14 @@ local workflow_limit = 100

local run_list_fields = "conclusion,displayTitle,event,headBranch,name,number,status,updatedAt,databaseId"

local function get_workflow_runs_sync()
local function get_workflow_runs_sync(opts)
opts = opts or {}

local lines = {}
local output, stderr = gh.run.list {
json = run_list_fields,
limit = workflow_limit,
branch = opts.branch,
opts = { mode = "sync" },
}
if stderr and not utils.is_blank(stderr) then
Expand All @@ -669,10 +672,17 @@ local function get_workflow_runs_sync()
or value.conclusion == "failure" and icons.failed
or ""

local display
if opts.branch == nil then
display = string.format("%s (%s)", value.name, value.headBranch)
else
display = value.name
end

local wf_run = {
status = status,
title = value.displayTitle,
display = value.displayTitle .. " " .. conclusion,
display = display .. " " .. conclusion,
value = value.databaseId,
branch = value.headBranch,
name = value.name,
Expand Down Expand Up @@ -700,9 +710,9 @@ M.previewer = function(self, entry)
populate_preview_buffer(id, self.state.bufnr)
end

M.list = function()
M.list = function(opts)
utils.info "Fetching workflow runs (this may take a while) ..."
local wf_runs = get_workflow_runs_sync()
local wf_runs = get_workflow_runs_sync(opts)

require("octo.picker").workflow_runs(wf_runs, "Workflow runs", render)
end
Expand Down

0 comments on commit 4f91b27

Please sign in to comment.