Add manual delete git branch#8618
Open
solababs wants to merge 4 commits intosb-13032026-delete-git-branch-after-merge-ifc-2336from
Open
Add manual delete git branch#8618solababs wants to merge 4 commits intosb-13032026-delete-git-branch-after-merge-ifc-2336from
solababs wants to merge 4 commits intosb-13032026-delete-git-branch-after-merge-ifc-2336from
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…o sb-13032026-manual-delete-branch-ifc-2336
ajtmccarty
approved these changes
Mar 17, 2026
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.
Why
There is no way to trigger Git branch deletion on-demand when manually deleting an Infrahub branch — the automatic
delete_git_branch_after_mergesetting only applies to the merge flow. A user who merges without the config enabled, or who wants per-branch control, has no option today.This PR adds
delete_from_git: Booleanto theBranchDeleteGraphQL mutation so callers can opt into Git branch deletion at call time, regardless of the global config.What changed
backend/infrahub/graphql/mutations/branch.py— newBranchDeleteInputtype withnameanddelete_from_git: Boolean(defaultfalse).BranchDeletenow usesBranchDeleteInputinstead ofBranchNameInput, and passesdelete_from_gitthrough to both theexecute_workflowandsubmit_workflowcall sites.backend/infrahub/core/branch/tasks.py—delete_branch()flow now acceptsdelete_from_git: bool = False. Theshould_delete_gitcondition becomes(config.SETTINGS.main.delete_git_branch_after_merge or delete_from_git) and obj.sync_with_git— either the global setting or the explicit flag triggers Git deletion.backend/tests/functional/branch/test_delete_git_branch.py— 2 new tests appended to the existing class:delete_from_git=Truewith config disabled triggersGIT_REPOSITORIES_DELETE_BRANCH;delete_from_git=Falsewith config disabled does not.BranchNameInputis unchanged and still used by other mutations — no existing callers ofBranchDeleteare broken sincedelete_from_gitdefaults tofalse.Suggested review order
BranchDeleteInput+ updatedmutate()delete_branch()signature and conditionHow to review
bool(data.delete_from_git)is the right coercion — GraphQLBooleanwithdefault_value=Falseshould always produce a bool, but the explicit cast is a safe guard.orcondition inshould_delete_gitmeans either the global config or the per-call flag can enable Git deletion. Verify this is intentional and matches FR-008/FR-009.BranchNameInputis intentionally kept unchanged — other mutations (BranchMerge, etc.) still use it.How to test
Manual flow:
delete_git_branch_after_merge = false(default), callBranchDeletewithdelete_from_git: trueon async_with_git=Truebranch — Git branch should be deleted.BranchDeletewithdelete_from_git: falseon async_with_git=Truebranch — Git branch should be retained.delete_from_gitentirely — existing behaviour unchanged.Impact & rollout
delete_from_gitis optional and defaults tofalse; existingBranchDeletecallers are unaffected.Checklist
uv run towncrier create ...)