提交 7494a1b9 编写于 作者: J João Moreno 提交者: GitHub

Merge pull request #27136 from dmportella/gpg-support

GPG support 
......@@ -678,6 +678,11 @@
"type": "boolean",
"description": "%config.enableSmartCommit%",
"default": false
},
"git.enableCommitSigning": {
"type": "boolean",
"description": "%config.enableCommitSigning%",
"default": false
}
}
}
......
......@@ -44,5 +44,6 @@
"config.ignoreLegacyWarning": "Ignores the legacy Git warning",
"config.ignoreLimitWarning": "Ignores the warning when there are too many changes in a repository",
"config.defaultCloneDirectory": "The default location where to clone a git repository",
"config.enableSmartCommit": "Commit all changes when there are no staged changes."
"config.enableSmartCommit": "Commit all changes when there are no staged changes.",
"config.enableCommitSigning": "Enables commit signing with GPG."
}
\ No newline at end of file
......@@ -600,6 +600,7 @@ export class CommandCenter {
): Promise<boolean> {
const config = workspace.getConfiguration('git');
const enableSmartCommit = config.get<boolean>('enableSmartCommit') === true;
const enableCommitSigning = config.get<boolean>('enableCommitSigning') === true;
const noStagedChanges = this.model.indexGroup.resources.length === 0;
const noUnstagedChanges = this.model.workingTreeGroup.resources.length === 0;
......@@ -623,6 +624,9 @@ export class CommandCenter {
opts = { all: noStagedChanges };
}
// enable signing of commits if configurated
opts.signCommit = enableCommitSigning;
if (
// no changes
(noStagedChanges && noUnstagedChanges)
......
......@@ -612,7 +612,7 @@ export class Repository {
}
}
async commit(message: string, opts: { all?: boolean, amend?: boolean, signoff?: boolean } = Object.create(null)): Promise<void> {
async commit(message: string, opts: { all?: boolean, amend?: boolean, signoff?: boolean, signCommit?: boolean } = Object.create(null)): Promise<void> {
const args = ['commit', '--quiet', '--allow-empty-message', '--file', '-'];
if (opts.all) {
......@@ -627,6 +627,10 @@ export class Repository {
args.push('--signoff');
}
if (opts.signCommit) {
args.push('-S');
}
try {
await this.run(args, { input: message || '' });
} catch (commitErr) {
......
......@@ -290,6 +290,7 @@ export interface CommitOptions {
all?: boolean;
amend?: boolean;
signoff?: boolean;
signCommit?: boolean;
}
export class Model implements Disposable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册