[WIP] Added support for -S for signing git commits

Ticket #5065
This commit is contained in:
Daniel Portella 2017-05-23 12:47:23 +01:00
parent 2ae81ab6ec
commit d266d9a994
4 changed files with 12 additions and 2 deletions

View file

@ -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."
}

View 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)

View file

@ -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) {

View file

@ -290,6 +290,7 @@ export interface CommitOptions {
all?: boolean;
amend?: boolean;
signoff?: boolean;
signCommit?: boolean;
}
export class Model implements Disposable {