Skip to content

Commit 14deecd

Browse files
authored
Merge pull request #824 from ianhi/fix-discard-all
check for changed files when discarding all changes
2 parents 432395b + 2fe24e2 commit 14deecd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/model.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,21 +383,25 @@ export class GitExtension implements IGitExtension {
383383
const data = await this._taskHandler.execute<Git.ICheckoutResult>(
384384
'git:checkout',
385385
async () => {
386-
const d = await requestAPI<Git.ICheckoutResult>(
387-
'checkout',
388-
'POST',
389-
body
390-
);
391-
386+
let changes;
392387
if (body.checkout_branch) {
393-
const changes = await this._changedFiles(
388+
changes = await this._changedFiles(
394389
this._currentBranch.name,
395390
body.branchname
396391
);
397-
changes.files?.forEach(file => this._revertFile(file));
392+
} else if (body.filename) {
393+
changes = { files: [body.filename] };
398394
} else {
399-
this._revertFile(options.filename);
395+
changes = await this._changedFiles('WORKING', 'HEAD');
400396
}
397+
398+
const d = await requestAPI<Git.ICheckoutResult>(
399+
'checkout',
400+
'POST',
401+
body
402+
);
403+
404+
changes.files?.forEach(file => this._revertFile(file));
401405
return d;
402406
}
403407
);

0 commit comments

Comments
 (0)