Skip to content

Commit 7780e3d

Browse files
committed
Stash
1 parent 0ac816b commit 7780e3d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/commands.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ import { PRNode } from './view/treeNodes/pullRequestNode';
4848
import { RepositoryChangesNode } from './view/treeNodes/repositoryChangesNode';
4949

5050
// Modal dialog options for handling uncommitted changes during PR checkout
51-
const STAGE_CHANGES = vscode.l10n.t('Stage changes');
51+
const STASH_CHANGES = vscode.l10n.t('Stash changes');
5252
const DISCARD_CHANGES = vscode.l10n.t('Discard changes');
53-
const CANCEL_CHECKOUT = vscode.l10n.t('Cancel');
5453

5554
/**
5655
* Shows a modal dialog when there are uncommitted changes during PR checkout
@@ -60,7 +59,7 @@ const CANCEL_CHECKOUT = vscode.l10n.t('Cancel');
6059
async function handleUncommittedChanges(repository: Repository): Promise<boolean> {
6160
const hasWorkingTreeChanges = repository.state.workingTreeChanges.length > 0;
6261
const hasIndexChanges = repository.state.indexChanges.length > 0;
63-
62+
6463
if (!hasWorkingTreeChanges && !hasIndexChanges) {
6564
return true; // No uncommitted changes, proceed
6665
}
@@ -71,24 +70,24 @@ async function handleUncommittedChanges(repository: Repository): Promise<boolean
7170
modal: true,
7271
detail: vscode.l10n.t('Choose how to handle your uncommitted changes before checking out the pull request.'),
7372
},
74-
STAGE_CHANGES,
73+
STASH_CHANGES,
7574
DISCARD_CHANGES,
76-
CANCEL_CHECKOUT,
7775
);
7876

79-
if (!modalResult || modalResult === CANCEL_CHECKOUT) {
77+
if (!modalResult) {
8078
return false; // User cancelled
8179
}
8280

8381
try {
84-
if (modalResult === STAGE_CHANGES) {
85-
// Stage all changes (working tree changes + any unstaged changes)
82+
if (modalResult === STASH_CHANGES) {
83+
// Stash all changes (working tree changes + any unstaged changes)
8684
const allChangedFiles = [
8785
...repository.state.workingTreeChanges.map(change => change.uri.fsPath),
8886
...repository.state.indexChanges.map(change => change.uri.fsPath),
8987
];
9088
if (allChangedFiles.length > 0) {
9189
await repository.add(allChangedFiles);
90+
await vscode.commands.executeCommand('git.stash', repository);
9291
}
9392
} else if (modalResult === DISCARD_CHANGES) {
9493
// Discard all working tree changes

0 commit comments

Comments
 (0)