feat(repositories): add delete_branch tool#2790
Open
huzaifa678 wants to merge 1 commit into
Open
Conversation
The repositories toolset exposes create_branch and list_branches but provides no way to delete a branch. This adds a delete_branch tool that fills that gap, following the existing create_branch implementation. As a guardrail, the tool fetches the branch first and refuses to delete protected branches, returning a clear error to the model instead of attempting the deletion. It requires owner, repo, and branch, is scoped to `repo`, and is annotated as a non-read-only operation. Tests cover successful deletion, protected-branch refusal, branch not found, and deletion failure. Closes github#1476
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
delete_branchtool to the repositories toolset, resolving #1476.The repo already exposes
create_branchandlist_branchesbut had no way to delete a branch. This fills that gap, following the existingcreate_branchimplementation pattern.Guardrail
As requested in the issue, the tool will not delete a protected branch. It fetches the branch first and, if
protectedis true, returns a tool error rather than attempting the deletion — giving the model actionable feedback.Behavior
delete_branchowner,repo,branchReadOnlyHintfalserepoFlow:
GET /repos/{owner}/{repo}/branches/{branch}→ check protection statusDELETE /repos/{owner}/{repo}/git/refs/heads/{branch}Testing
Test_DeleteBranchcovers:Verified locally:
go test ./...— passgolangci-lint run— 0 issuesscript/generate-docs— README updatedUPDATE_TOOLSNAPS=true go test ./...— snapshot committedChecklist
script/lintpassespkg/github/__toolsnaps__/delete_branch.snap)script/generate-docsCloses #1476