Skip to content

Commit 5b20d72

Browse files
Copilotalexr00
andcommitted
Fix notification to only mention branch switch when branch was active
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 2a16d89 commit 5b20d72

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/github/pullRequestReviewCommon.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ export namespace PullRequestReviewCommon {
432432
const branchInfo = await folderRepositoryManager.getBranchNameForPullRequest(item);
433433
const defaultBranch = await folderRepositoryManager.getPullRequestRepositoryDefaultBranch(item);
434434

435+
// Check if the branch is currently active before deletion
436+
const isBranchActive = item.equals(folderRepositoryManager.activePullRequest) || (folderRepositoryManager.repository.state.HEAD?.name && folderRepositoryManager.repository.state.HEAD.name === branchInfo?.branch);
437+
435438
// Get user preferences for automatic deletion
436439
const deleteLocalBranch = vscode.workspace
437440
.getConfiguration(PR_SETTINGS_NAMESPACE)
@@ -470,14 +473,18 @@ export namespace PullRequestReviewCommon {
470473
const wasRemoteDeleted = deletedBranchTypes.includes('remoteHead') || deletedBranchTypes.includes('remote');
471474
const branchName = branchInfo?.branch || item.head?.ref || vscode.l10n.t('branch');
472475

473-
if (wasLocalDeleted && wasRemoteDeleted) {
476+
if (wasLocalDeleted && isBranchActive && wasRemoteDeleted) {
474477
vscode.window.showInformationMessage(
475478
vscode.l10n.t('Deleted local and remote branches for {0} and switched to {1}.', branchName, defaultBranch)
476479
);
477-
} else if (wasLocalDeleted) {
480+
} else if (wasLocalDeleted && isBranchActive) {
478481
vscode.window.showInformationMessage(
479482
vscode.l10n.t('Deleted local branch {0} and switched to {1}.', branchName, defaultBranch)
480483
);
484+
} else if (wasLocalDeleted) {
485+
vscode.window.showInformationMessage(
486+
vscode.l10n.t('Deleted local branch {0}.', branchName)
487+
);
481488
} else {
482489
vscode.window.showInformationMessage(
483490
vscode.l10n.t('Deleted remote branch {0}.', branchName)

0 commit comments

Comments
 (0)