mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 21:11:38 +01:00
💄
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user