mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
💄
This commit is contained in:
parent
eb1cea5432
commit
08d271585d
|
@ -1751,6 +1751,22 @@
|
|||
"description": "%config.enableStatusBarSync%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"git.promptToSaveFilesBeforeStash": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"always",
|
||||
"staged",
|
||||
"never"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"%config.promptToSaveFilesBeforeStash.always%",
|
||||
"%config.promptToSaveFilesBeforeStash.staged%",
|
||||
"%config.promptToSaveFilesBeforeStash.never%"
|
||||
],
|
||||
"scope": "resource",
|
||||
"default": "always",
|
||||
"description": "%config.promptToSaveFilesBeforeStash%"
|
||||
},
|
||||
"git.promptToSaveFilesBeforeCommit": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
|
@ -121,6 +121,10 @@
|
|||
"config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.",
|
||||
"config.decorations.enabled": "Controls whether Git contributes colors and badges to the explorer and the open editors view.",
|
||||
"config.enableStatusBarSync": "Controls whether the Git Sync command appears in the status bar.",
|
||||
"config.promptToSaveFilesBeforeStash": "Controls whether Git should check for unsaved files before stashing changes.",
|
||||
"config.promptToSaveFilesBeforeStash.always": "Check for any unsaved files.",
|
||||
"config.promptToSaveFilesBeforeStash.staged": "Check only for unsaved staged files.",
|
||||
"config.promptToSaveFilesBeforeStash.never": "Disable this check.",
|
||||
"config.promptToSaveFilesBeforeCommit": "Controls whether Git should check for unsaved files before committing.",
|
||||
"config.promptToSaveFilesBeforeCommit.always": "Check for any unsaved files.",
|
||||
"config.promptToSaveFilesBeforeCommit.staged": "Check only for unsaved staged files.",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue