Browse Source

Fixes issues with stash command errors

main
Eric Amodio 4 years ago
parent
commit
a182660a4d
2 changed files with 29 additions and 14 deletions
  1. +11
    -7
      src/commands/git/stash.ts
  2. +18
    -7
      src/system/decorators/gate.ts

+ 11
- 7
src/commands/git/stash.ts View File

@ -274,11 +274,15 @@ export class StashGitCommand extends QuickCommandBase {
) )
) { ) {
void window.showWarningMessage( void window.showWarningMessage(
'Unable to apply stash. Your working tree changes would be overwritten'
'Unable to apply stash. Your working tree changes would be overwritten. Please commit or stash your changes before trying again'
); );
return undefined; return undefined;
} else if (ex.message.includes('Auto-merging') && ex.message.includes('CONFLICT')) {
} else if (
(ex.message.includes('Auto-merging') && ex.message.includes('CONFLICT')) ||
(ex.stdout?.includes('Auto-merging') && ex.stdout?.includes('CONFLICT')) ||
ex.stdout?.includes('needs merge')
) {
void window.showInformationMessage('Stash applied with conflicts'); void window.showInformationMessage('Stash applied with conflicts');
return undefined; return undefined;
@ -445,7 +449,7 @@ export class StashGitCommand extends QuickCommandBase {
state.subcommand = selection[0].command; state.subcommand = selection[0].command;
} }
void state.repo.stashApply(state.stash!.stashName, { deleteAfter: state.subcommand === 'pop' });
void (await state.repo.stashApply(state.stash!.stashName, { deleteAfter: state.subcommand === 'pop' }));
throw new BreakQuickCommand(); throw new BreakQuickCommand();
} }
@ -556,7 +560,7 @@ export class StashGitCommand extends QuickCommandBase {
break; break;
} }
void state.repo.stashDelete(state.stash.stashName);
void (await state.repo.stashDelete(state.stash.stashName));
throw new BreakQuickCommand(); throw new BreakQuickCommand();
} }
@ -653,7 +657,7 @@ export class StashGitCommand extends QuickCommandBase {
const command = selection[0]; const command = selection[0];
if (command instanceof CommandQuickPickItem) { if (command instanceof CommandQuickPickItem) {
command.execute();
void (await command.execute());
throw new BreakQuickCommand(); throw new BreakQuickCommand();
} }
@ -743,10 +747,10 @@ export class StashGitCommand extends QuickCommandBase {
state.flags = selection[0].item; state.flags = selection[0].item;
} }
void state.repo.stashSave(state.message, state.uris, {
void (await state.repo.stashSave(state.message, state.uris, {
includeUntracked: state.flags.includes('--include-untracked'), includeUntracked: state.flags.includes('--include-untracked'),
keepIndex: state.flags.includes('--keep-index') keepIndex: state.flags.includes('--keep-index')
});
}));
throw new BreakQuickCommand(); throw new BreakQuickCommand();
} }

+ 18
- 7
src/system/decorators/gate.ts View File

@ -45,15 +45,26 @@ export function gate any>(resolver?: (...args: Parame
let promise = this[prop]; let promise = this[prop];
if (promise === undefined) { if (promise === undefined) {
const result = fn!.apply(this, args);
if (result == null || !Promises.is(result)) {
return result;
}
let result;
try {
result = fn!.apply(this, args);
if (result == null || !Promises.is(result)) {
return result;
}
this[prop] = promise = result.then((r: any) => {
this[prop] = promise = result
.then((r: any) => {
this[prop] = undefined;
return r;
})
.catch(ex => {
this[prop] = undefined;
throw ex;
});
} catch (ex) {
this[prop] = undefined; this[prop] = undefined;
return r;
});
throw ex;
}
} }
return promise; return promise;

Loading…
Cancel
Save