Skip to content

Commit 4f921f8

Browse files
committed
simplify exception handler & remove retry
1 parent 6808e64 commit 4f921f8

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

src/commands/git/revert.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,16 @@ export class RevertGitCommand extends QuickCommand<State> {
8383
try {
8484
await state.repo.git.revert(ref.ref, state.options);
8585
} catch (ex) {
86-
if (ex instanceof RevertError) {
87-
let shouldRetry = false;
88-
if (ex.reason === RevertErrorReason.LocalChangesWouldBeOverwritten) {
89-
const response = await showShouldCommitOrStashPrompt();
90-
if (response === 'Stash') {
91-
await executeCommand(Commands.GitCommandsStashPush);
92-
shouldRetry = true;
93-
} else if (response === 'Commit') {
94-
await executeCoreCommand('workbench.view.scm');
95-
shouldRetry = true;
96-
} else {
97-
continue;
98-
}
86+
if (RevertError.is(ex, RevertErrorReason.LocalChangesWouldBeOverwritten)) {
87+
const response = await showShouldCommitOrStashPrompt();
88+
if (response == null || response === 'Cancel') {
89+
continue;
9990
}
10091

101-
if (shouldRetry) {
102-
try {
103-
await state.repo.git.revert(ref.ref, state.flags);
104-
} catch (ex) {
105-
Logger.error(ex, this.title);
106-
void showGenericErrorMessage(ex.message);
107-
}
92+
if (response === 'Stash') {
93+
await executeCommand(Commands.GitCommandsStashPush);
94+
} else if (response === 'Commit') {
95+
await executeCoreCommand('workbench.view.scm');
10896
}
10997

11098
continue;

0 commit comments

Comments
 (0)