Skip to content

Prompt for local branch cleanup after GitHub auto-delete - #8908

Merged
Alex Ross (alexr00) merged 6 commits into
mainfrom
copilot/fix-local-branch-delete-prompt
Aug 27, 2026
Merged

Prompt for local branch cleanup after GitHub auto-delete#8908
Alex Ross (alexr00) merged 6 commits into
mainfrom
copilot/fix-local-branch-delete-prompt

Conversation

Copilot AI commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

When GitHub automatically deleted a merged PR’s remote branch, VS Code skipped local cleanup, leaving the PR branch checked out.

Changes

  • Centralize post-merge branch cleanup.
  • Preserve extension-configured automatic deletion.
  • When GitHub’s delete_branch_on_merge is enabled, open the existing deletion picker for local cleanup.
  • Apply the behavior to both PR webview merge paths.
  • Report merge success before prompting and prevent cleanup failures from masking successful merges.
if (deleteBranchAfterMerge) {
  await autoDeleteBranchesAfterMerge(...);
} else if (metadata.delete_branch_on_merge) {
  return deleteBranch(...);
}

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI and others added 3 commits August 27, 2026 11:42
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix local branch deletion prompt after auto merge in VS Code Prompt for local branch cleanup after GitHub auto-delete Aug 27, 2026
const deleteBranchAfterMerge = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(DELETE_BRANCH_AFTER_MERGE, false);
if (deleteBranchAfterMerge) {
await autoDeleteBranchesAfterMerge(folderRepositoryManager, item);
} else if ((await item.githubRepository.getMetadata()).delete_branch_on_merge) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to key off of github "delete on merge" setting.

@alexr00

Copy link
Copy Markdown
Member

Copilot I don't see any more commits

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>

Copilot AI commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Copilot I don't see any more commits

Addressed in 494f592: cleanup prompting now follows any successful merge when extension automatic cleanup is disabled, without reading GitHub’s delete-on-merge setting.

@alexr00
Alex Ross (alexr00) marked this pull request as ready for review August 27, 2026 15:18
Copilot AI lite review requested due to automatic review settings August 27, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a merge-flow gap where, if GitHub auto-deletes the remote branch after merging, the extension can skip the local cleanup flow (leaving the PR branch checked out). It centralizes post-merge branch cleanup behavior and ensures merge success is reported before any cleanup prompting occurs.

Changes:

  • Introduces a centralized handleBranchDeletionAfterMerge helper to coordinate post-merge cleanup (auto-delete vs. prompt based on repo metadata).
  • Updates both merge entry points (PR overview webview + activity bar view) to report merge success first, then perform/prompt for cleanup without masking a successful merge on cleanup failure.
  • Adds a test to ensure the local deletion picker is shown when GitHub’s delete_branch_on_merge is enabled.
Show a summary per file
File Description
src/test/github/pullRequestOverview.test.ts Adds coverage asserting the deletion picker is shown and merge success is replied before prompting.
src/github/pullRequestReviewCommon.ts Centralizes post-merge cleanup logic and adds guarded error logging for cleanup failures.
src/github/pullRequestOverview.ts Uses the centralized cleanup helper after replying merge success, then posts cleanup messages if needed.
src/github/activityBarViewProvider.ts Aligns the activity bar merge flow with the centralized post-merge cleanup behavior.
src/@types/vscode.proposed.chatParticipantAdditions.d.ts Updates the proposed chat participant type definition for auto-mode routing resolution.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/github/pullRequestReviewCommon.ts
@alexr00
Alex Ross (alexr00) merged commit d97ebb8 into main Aug 27, 2026
7 checks passed
@alexr00
Alex Ross (alexr00) deleted the copilot/fix-local-branch-delete-prompt branch August 27, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants