Skip to content

Commit

Permalink
simplify exception handler & remove retry
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiolms committed Dec 5, 2024
1 parent 6808e64 commit 4f921f8
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/commands/git/revert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,16 @@ export class RevertGitCommand extends QuickCommand<State> {
try {
await state.repo.git.revert(ref.ref, state.options);
} catch (ex) {
if (ex instanceof RevertError) {
let shouldRetry = false;
if (ex.reason === RevertErrorReason.LocalChangesWouldBeOverwritten) {
const response = await showShouldCommitOrStashPrompt();
if (response === 'Stash') {
await executeCommand(Commands.GitCommandsStashPush);
shouldRetry = true;
} else if (response === 'Commit') {
await executeCoreCommand('workbench.view.scm');
shouldRetry = true;
} else {
continue;
}
if (RevertError.is(ex, RevertErrorReason.LocalChangesWouldBeOverwritten)) {
const response = await showShouldCommitOrStashPrompt();
if (response == null || response === 'Cancel') {
continue;
}

if (shouldRetry) {
try {
await state.repo.git.revert(ref.ref, state.flags);
} catch (ex) {
Logger.error(ex, this.title);
void showGenericErrorMessage(ex.message);
}
if (response === 'Stash') {
await executeCommand(Commands.GitCommandsStashPush);
} else if (response === 'Commit') {
await executeCoreCommand('workbench.view.scm');
}

continue;
Expand Down

0 comments on commit 4f921f8

Please sign in to comment.