This commit is contained in:
João Moreno
2020-11-05 15:33:07 +01:00
parent eb1cea5432
commit 08d271585d
3 changed files with 24 additions and 14 deletions

View File

@@ -2424,27 +2424,20 @@ export class CommandCenter {
}
const config = workspace.getConfiguration('git', Uri.file(repository.root));
let promptToSaveFilesBeforeCommit = config.get<'always' | 'staged' | 'never'>('promptToSaveFilesBeforeCommit');
const promptToSaveFilesBeforeStashing = config.get<'always' | 'staged' | 'never'>('promptToSaveFilesBeforeStash');
// migration
if (promptToSaveFilesBeforeCommit as any === true) {
promptToSaveFilesBeforeCommit = 'always';
} else if (promptToSaveFilesBeforeCommit as any === false) {
promptToSaveFilesBeforeCommit = 'never';
}
if (promptToSaveFilesBeforeCommit !== 'never') {
if (promptToSaveFilesBeforeStashing !== 'never') {
let documents = workspace.textDocuments
.filter(d => !d.isUntitled && d.isDirty && isDescendant(repository.root, d.uri.fsPath));
if (promptToSaveFilesBeforeCommit === 'staged' || repository.indexGroup.resourceStates.length > 0) {
if (promptToSaveFilesBeforeStashing === 'staged' || repository.indexGroup.resourceStates.length > 0) {
documents = documents
.filter(d => repository.indexGroup.resourceStates.some(s => pathEquals(s.resourceUri.fsPath, d.uri.fsPath)));
}
if (documents.length > 0) {
const message = documents.length === 1
? localize('unsaved stash files single', "The following file has unsaved changes which won't be included in the stash if you proceed: {0}.\n\nWould you like to save it before committing?", path.basename(documents[0].uri.fsPath))
? localize('unsaved stash files single', "The following file has unsaved changes which won't be included in the stash if you proceed: {0}.\n\nWould you like to save it before stashing?", path.basename(documents[0].uri.fsPath))
: localize('unsaved stash files', "There are {0} unsaved files.\n\nWould you like to save them before stashing?", documents.length);
const saveAndStash = localize('save and stash', "Save All & Stash");
const stash = localize('stash', "Stash Anyway");
@@ -2452,9 +2445,6 @@ export class CommandCenter {
if (pick === saveAndStash) {
await Promise.all(documents.map(d => d.save()));
if (!includeUntracked) {
await repository.add(documents.map(d => d.uri));
}
} else if (pick !== stash) {
return; // do not stash on cancel
}