diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index bc8bc381786..26442a8d922 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -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 diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 31f4fcf408a..0c459f02cf9 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -600,6 +600,7 @@ export class CommandCenter { ): Promise { const config = workspace.getConfiguration('git'); const enableSmartCommit = config.get('enableSmartCommit') === true; + const enableCommitSigning = config.get('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) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index c0e643f44d5..8daf58eddc4 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -612,7 +612,7 @@ export class Repository { } } - async commit(message: string, opts: { all?: boolean, amend?: boolean, signoff?: boolean } = Object.create(null)): Promise { + async commit(message: string, opts: { all?: boolean, amend?: boolean, signoff?: boolean, signCommit?: boolean} = Object.create(null)): Promise { 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) { diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index 7d852bc8a39..58f0e59c47a 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -290,6 +290,7 @@ export interface CommitOptions { all?: boolean; amend?: boolean; signoff?: boolean; + signCommit?: boolean; } export class Model implements Disposable {