mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Git - Fix bug related to Stash & Checkout (#171099)
This commit is contained in:
parent
12515569ae
commit
b2b0642c45
|
@ -2070,11 +2070,12 @@ export class CommandCenter {
|
||||||
await this.cleanAll(repository);
|
await this.cleanAll(repository);
|
||||||
await item.run(opts);
|
await item.run(opts);
|
||||||
} else if (choice === stash || choice === migrate) {
|
} else if (choice === stash || choice === migrate) {
|
||||||
await this.stash(repository);
|
if (await this._stash(repository)) {
|
||||||
await item.run(opts);
|
await item.run(opts);
|
||||||
|
|
||||||
if (choice === migrate) {
|
if (choice === migrate) {
|
||||||
await this.stashPopLatest(repository);
|
await this.stashPopLatest(repository);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2982,7 +2983,7 @@ export class CommandCenter {
|
||||||
await commands.executeCommand('revealFileInOS', resourceState.resourceUri);
|
await commands.executeCommand('revealFileInOS', resourceState.resourceUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _stash(repository: Repository, includeUntracked = false, staged = false): Promise<void> {
|
private async _stash(repository: Repository, includeUntracked = false, staged = false): Promise<boolean> {
|
||||||
const noUnstagedChanges = repository.workingTreeGroup.resourceStates.length === 0
|
const noUnstagedChanges = repository.workingTreeGroup.resourceStates.length === 0
|
||||||
&& (!includeUntracked || repository.untrackedGroup.resourceStates.length === 0);
|
&& (!includeUntracked || repository.untrackedGroup.resourceStates.length === 0);
|
||||||
const noStagedChanges = repository.indexGroup.resourceStates.length === 0;
|
const noStagedChanges = repository.indexGroup.resourceStates.length === 0;
|
||||||
|
@ -2990,12 +2991,12 @@ export class CommandCenter {
|
||||||
if (staged) {
|
if (staged) {
|
||||||
if (noStagedChanges) {
|
if (noStagedChanges) {
|
||||||
window.showInformationMessage(l10n.t('There are no staged changes to stash.'));
|
window.showInformationMessage(l10n.t('There are no staged changes to stash.'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (noUnstagedChanges && noStagedChanges) {
|
if (noUnstagedChanges && noStagedChanges) {
|
||||||
window.showInformationMessage(l10n.t('There are no changes to stash.'));
|
window.showInformationMessage(l10n.t('There are no changes to stash.'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3022,7 +3023,7 @@ export class CommandCenter {
|
||||||
if (pick === saveAndStash) {
|
if (pick === saveAndStash) {
|
||||||
await Promise.all(documents.map(d => d.save()));
|
await Promise.all(documents.map(d => d.save()));
|
||||||
} else if (pick !== stash) {
|
} else if (pick !== stash) {
|
||||||
return; // do not stash on cancel
|
return false; // do not stash on cancel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3040,15 +3041,16 @@ export class CommandCenter {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof message === 'undefined') {
|
if (typeof message === 'undefined') {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await repository.createStash(message, includeUntracked, staged);
|
await repository.createStash(message, includeUntracked, staged);
|
||||||
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (/You do not have the initial commit yet/.test(err.stderr || '')) {
|
if (/You do not have the initial commit yet/.test(err.stderr || '')) {
|
||||||
window.showInformationMessage(l10n.t('The repository does not have any commits. Please make an initial commit before creating a stash.'));
|
window.showInformationMessage(l10n.t('The repository does not have any commits. Please make an initial commit before creating a stash.'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -3056,18 +3058,18 @@ export class CommandCenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@command('git.stash', { repository: true })
|
@command('git.stash', { repository: true })
|
||||||
stash(repository: Repository): Promise<void> {
|
async stash(repository: Repository): Promise<void> {
|
||||||
return this._stash(repository);
|
await this._stash(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@command('git.stashStaged', { repository: true })
|
@command('git.stashStaged', { repository: true })
|
||||||
stashStaged(repository: Repository): Promise<void> {
|
async stashStaged(repository: Repository): Promise<void> {
|
||||||
return this._stash(repository, false, true);
|
await this._stash(repository, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@command('git.stashIncludeUntracked', { repository: true })
|
@command('git.stashIncludeUntracked', { repository: true })
|
||||||
stashIncludeUntracked(repository: Repository): Promise<void> {
|
async stashIncludeUntracked(repository: Repository): Promise<void> {
|
||||||
return this._stash(repository, true);
|
await this._stash(repository, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@command('git.stashPop', { repository: true })
|
@command('git.stashPop', { repository: true })
|
||||||
|
|
Loading…
Reference in a new issue