Skip to content

Commit

Permalink
Add :Octo label delete command (#867)
Browse files Browse the repository at this point in the history
* support label delete

* add to the documentation
  • Loading branch information
wd60622 authored Feb 19, 2025
1 parent 12f1fa8 commit b690c12
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ If no command is passed, the argument to `Octo` is treated as a URL from where a
| label | add [label] | Add a label from available label menu |
| | remove [label] | Remove a label |
| | create [label] | Create a new label |
| | delete [label] | Delete an existing label from repo |
| milestone | add [milestone] | Add a milestone to current Issue or PR |
| | remove | Remove a milestone from current Issue or PR |
| | create [milestone] | Create a new milestone |
Expand Down
1 change: 1 addition & 0 deletions doc/octo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ See |octo-command-examples| for examples.
add [label] Add specified label or from the available label menu.
remove [label] Remove the specified label or from the menu.
create [label] Create a new label.
delete [label] Delete the specific label or from the available label menu.


:Octo assignee [action] *octo-commands-assignee*
Expand Down
38 changes: 38 additions & 0 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,44 @@ function M.setup()
remove = function(label)
M.remove_label(label)
end,
delete = function(label)
local delete_labels = function(labels)
for _, label in ipairs(labels) do
if vim.fn.confirm("Delete label: " .. label.name .. "?", "&Yes\n&No", 2) == 1 then
gh.label.delete {
label.name,
yes = true,
opts = {
cb = gh.create_callback {
success = function()
utils.info("Deleted label: " .. label.name)
end,
},
},
}
else
utils.info("Skipped deleting label: " .. label.name)
end
end
end

local delete_labels_callback = function(labels)
if #labels == 0 then
utils.info "Nothing to delete"
return
end

delete_labels(labels)
end

if utils.is_blank(label) then
picker.labels {
cb = delete_labels_callback,
}
else
delete_labels { { name = label } }
end
end,
},
assignee = {
add = function(login)
Expand Down

0 comments on commit b690c12

Please sign in to comment.