提交 9b0eee12 编写于 作者: J Joao Moreno

💄 commit empty

上级 e2b2b5bc
...@@ -422,10 +422,6 @@ ...@@ -422,10 +422,6 @@
"command": "git.commit", "command": "git.commit",
"when": "config.git.enabled && gitOpenRepositoryCount != 0" "when": "config.git.enabled && gitOpenRepositoryCount != 0"
}, },
{
"command": "git.commitEmpty",
"when": "config.git.allowcommitEmptys && gitOpenRepositoryCount != 0"
},
{ {
"command": "git.commitStaged", "command": "git.commitStaged",
"when": "config.git.enabled && gitOpenRepositoryCount != 0" "when": "config.git.enabled && gitOpenRepositoryCount != 0"
...@@ -608,11 +604,6 @@ ...@@ -608,11 +604,6 @@
"group": "3_commit", "group": "3_commit",
"when": "scmProvider == git" "when": "scmProvider == git"
}, },
{
"command": "git.commitEmpty",
"group": "3_commit",
"when": "scmProvider == git"
},
{ {
"command": "git.commitStagedSigned", "command": "git.commitStagedSigned",
"group": "3_commit", "group": "3_commit",
...@@ -1005,11 +996,11 @@ ...@@ -1005,11 +996,11 @@
"description": "%config.enableCommitSigning%", "description": "%config.enableCommitSigning%",
"default": false "default": false
}, },
"git.allowEmptyCommits": { "git.confirmEmptyCommits": {
"type": "boolean", "type": "boolean",
"scope": "resource", "scope": "resource",
"description": "%config.allowEmptyCommits%", "description": "%config.confirmEmptyCommits%",
"default": false "default": true
}, },
"git.decorations.enabled": { "git.decorations.enabled": {
"type": "boolean", "type": "boolean",
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
"config.ignoredRepositories": "List of git repositories to ignore.", "config.ignoredRepositories": "List of git repositories to ignore.",
"config.showProgress": "Controls whether git actions should show progress.", "config.showProgress": "Controls whether git actions should show progress.",
"config.rebaseWhenSync": "Use rebase instead of merge when running the sync command.", "config.rebaseWhenSync": "Use rebase instead of merge when running the sync command.",
"config.confirmEmptyCommits": "Always confirm the creation of empty commits.",
"colors.modified": "Color for modified resources.", "colors.modified": "Color for modified resources.",
"colors.deleted": "Color for deleted resources.", "colors.deleted": "Color for deleted resources.",
"colors.untracked": "Color for untracked resources.", "colors.untracked": "Color for untracked resources.",
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
'use strict'; 'use strict';
import { Uri, commands, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControlResourceState, TextDocumentShowOptions, ViewColumn, ProgressLocation, TextEditor, MessageOptions } from 'vscode'; import { Uri, commands, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControlResourceState, TextDocumentShowOptions, ViewColumn, ProgressLocation, TextEditor, MessageOptions } from 'vscode';
import { Git } from './git'; import { Git, CommitOptions } from './git';
import { Repository, Resource, Status, CommitOptions, ResourceGroupType } from './repository'; import { Repository, Resource, Status, ResourceGroupType } from './repository';
import { Model } from './model'; import { Model } from './model';
import { toGitUri, fromGitUri } from './uri'; import { toGitUri, fromGitUri } from './uri';
import { grep, isDescendant, pathEquals } from './util'; import { grep, isDescendant, pathEquals } from './util';
...@@ -1087,11 +1087,11 @@ export class CommandCenter { ...@@ -1087,11 +1087,11 @@ export class CommandCenter {
if ( if (
( (
// no changes // no changes
(noStagedChanges && noUnstagedChanges) (noStagedChanges && noUnstagedChanges)
// or no staged changes and not `all` // or no staged changes and not `all`
|| (!opts.all && noStagedChanges) || (!opts.all && noStagedChanges)
) )
&& !opts.empty && !opts.empty
) { ) {
window.showInformationMessage(localize('no changes', "There are no changes to commit.")); window.showInformationMessage(localize('no changes', "There are no changes to commit."));
...@@ -1137,11 +1137,6 @@ export class CommandCenter { ...@@ -1137,11 +1137,6 @@ export class CommandCenter {
} }
} }
@command('git.commitEmpty', { repository: true})
async commit(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { empty: true });
}
@command('git.commit', { repository: true }) @command('git.commit', { repository: true })
async commit(repository: Repository): Promise<void> { async commit(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository); await this.commitWithAnyInput(repository);
...@@ -1190,6 +1185,28 @@ export class CommandCenter { ...@@ -1190,6 +1185,28 @@ export class CommandCenter {
await this.commitWithAnyInput(repository, { all: true, amend: true }); await this.commitWithAnyInput(repository, { all: true, amend: true });
} }
@command('git.commitEmpty', { repository: true })
async commitEmpty(repository: Repository): Promise<void> {
const root = Uri.file(repository.root);
const config = workspace.getConfiguration('git', root);
const shouldPrompt = config.get<boolean>('confirmEmptyCommits') === true;
if (shouldPrompt) {
const message = localize('confirm emtpy commit', "Are you sure you want to create an empty commit?");
const yes = localize('yes', "Yes");
const neverAgain = localize('yes never again', "Yes, Don't Show Again");
const pick = await window.showWarningMessage(message, { modal: true }, yes, neverAgain);
if (pick === neverAgain) {
await config.update('confirmEmptyCommits', false, true);
} else if (pick !== yes) {
return;
}
}
await this.commitWithAnyInput(repository, { empty: true });
}
@command('git.undoCommit', { repository: true }) @command('git.undoCommit', { repository: true })
async undoCommit(repository: Repository): Promise<void> { async undoCommit(repository: Repository): Promise<void> {
const HEAD = repository.HEAD; const HEAD = repository.HEAD;
......
...@@ -623,6 +623,14 @@ export function parseLsFiles(raw: string): LsFilesElement[] { ...@@ -623,6 +623,14 @@ export function parseLsFiles(raw: string): LsFilesElement[] {
.map(([, mode, object, stage, file]) => ({ mode, object, stage, file })); .map(([, mode, object, stage, file]) => ({ mode, object, stage, file }));
} }
export interface CommitOptions {
all?: boolean;
amend?: boolean;
signoff?: boolean;
signCommit?: boolean;
empty?: boolean;
}
export class Repository { export class Repository {
constructor( constructor(
...@@ -940,7 +948,7 @@ export class Repository { ...@@ -940,7 +948,7 @@ export class Repository {
} }
} }
async commit(message: string, opts: { all?: boolean, amend?: boolean, signoff?: boolean, signCommit?: boolean } = Object.create(null)): Promise<void> { async commit(message: string, opts: CommitOptions = Object.create(null)): Promise<void> {
const args = ['commit', '--quiet', '--allow-empty-message', '--file', '-']; const args = ['commit', '--quiet', '--allow-empty-message', '--file', '-'];
if (opts.all) { if (opts.all) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
'use strict'; 'use strict';
import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType } from 'vscode'; import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType } from 'vscode';
import { Repository as BaseRepository, Commit, Stash, GitError, Submodule } from './git'; import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions } from './git';
import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent } from './util'; import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent } from './util';
import { memoize, throttle, debounce } from './decorators'; import { memoize, throttle, debounce } from './decorators';
import { toGitUri } from './uri'; import { toGitUri } from './uri';
...@@ -390,14 +390,6 @@ class OperationsImpl implements Operations { ...@@ -390,14 +390,6 @@ class OperationsImpl implements Operations {
} }
} }
export interface CommitOptions {
all?: boolean;
amend?: boolean;
signoff?: boolean;
signCommit?: boolean;
empty?: boolean;
}
export interface GitResourceGroup extends SourceControlResourceGroup { export interface GitResourceGroup extends SourceControlResourceGroup {
resourceStates: Resource[]; resourceStates: Resource[];
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册