Support automatic branch cleanup and merge-method selection for reviews #51
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/51/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change adds provider-aware merge payloads and an optional automatic local branch cleanup flow when accepting/merging review requests.
Summary
statusandlastMergeSourceCommitfields.src-tauri/src/integrations/cleanup.rs. When a merge action is requested and acleanup_pathis provided, the integrations layer calls into a prepare step (which verifies the PR details remotely) before performing the merge and then runs a finish step after the merge to perform local repository cleanup.src-tauri/src/git/review_cleanup.rsimplements the local-side cleanup plan (prepareandfinish). It validates branches and remotes, checks worktree cleanliness, verifies remote/local SHAs, performs authenticated fetches, fast-forwards or checks out the target branch, and removes the PR branch both remotely (using expected-old-value deletion when safe) and locally (removing branch refs and associated branch config). Several safety checks prevent destructive actions when the local repo or remote have diverged or when the branch is in use in another worktree.src-tauri/src/git/review_cleanup.rs. They cover normal deletion after merge (including squash/merge), acceptance of server-side deletion, preservation of dirty or unpushed local work, concurrent local/remote commits, and protection against mismatched remotes or active worktrees.git::review_cleanupis exported viasrc-tauri/src/git.rs, andintegrations::mergehelpers are used for generating payloads. A minor doc/template tweak was made insrc-tauri/crates/commit_ai/src/cloud.rs(Markdown formatting text).Key behavior changes
merge_method: Option<String>andcleanup_path: Option<String>.merge_methodis provided for a merge action, the code validates and uses provider-specific payloads (viamerge_payload) when issuing the merge request.cleanup_pathis provided and the action ismerge, the integrations code attempts to prepare a cleanup plan (remote PR verification + local checks) before performing the merge; on success it will call the cleanup finish step after the merge completes.Why this matters (evidence-based)
statusand the merge commit id.integrations/cleanup.rsmodule reads the PR payload from the provider API and maps it to aCleanupPlan. Thegit/review_cleanup.rsmodule contains the implementation for local verification and safe deletion operations, including comprehensive checks and explicit fetch/push operations with authentication.Testing
src-tauri/src/git/review_cleanup.rsexercising the cleanup logic, but no test execution results were provided.Recommended reviewer checks
cd src-tauri && cargo test(or run your workspace's normal test command).merge_payloadoutputs expected JSON forgithub,gitlab,gitea, andazure-devops, and that the integrations code sends that payload whenmerge_methodis set.git/review_cleanup.rsfor the intended safety invariants (worktree cleanliness, remote URL matching, expected-old-value push deletion) and confirm they align with expected repository-local policies.run_integration_review_actionif they exist, since its signature now includesmerge_methodandcleanup_pathoptional parameters.Compatibility and reviewer action
run_integration_review_actioninterface. Any code that calls this function directly inside the codebase must be updated to pass the new parameters (orNone) as appropriate.cleanup_path) when the local repository path refers to a trusted checkout matching the PR's remote.No test execution results were provided.