From d4c6affe13fd41a92c048fc02a56867cf78c6e87 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Tue, 9 Aug 2022 12:14:56 +0300 Subject: [PATCH] Commit keyboard shortcut to honor the post commit command setting (#157617) --- extensions/git/src/repository.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 2cbddcc0cafdc..1838b3213e835 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -914,7 +914,6 @@ export class Repository implements Disposable { const root = Uri.file(repository.root); this._sourceControl = scm.createSourceControl('git', 'Git', root); - this._sourceControl.acceptInputCommand = { command: 'git.commit', title: localize('commit', "Commit"), arguments: [this._sourceControl] }; this._sourceControl.quickDiffProvider = this; this._sourceControl.inputBox.validateInput = this.validateInput.bind(this); this.disposables.push(this._sourceControl); @@ -951,6 +950,17 @@ export class Repository implements Disposable { || e.affectsConfiguration('git.showActionButton', root) )(this.updateModelState, this, this.disposables); + const updateInputBoxAcceptInputCommand = () => { + const config = workspace.getConfiguration('git', root); + const postCommitCommand = config.get('postCommitCommand'); + const postCommitCommandArg = postCommitCommand === 'push' || postCommitCommand === 'sync' ? `git.${postCommitCommand}` : ''; + this._sourceControl.acceptInputCommand = { command: 'git.commit', title: localize('commit', "Commit"), arguments: [this._sourceControl, postCommitCommandArg] }; + }; + + const onConfigListenerForPostCommitCommand = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.postCommitCommand', root)); + onConfigListenerForPostCommitCommand(updateInputBoxAcceptInputCommand, this, this.disposables); + updateInputBoxAcceptInputCommand(); + const updateInputBoxVisibility = () => { const config = workspace.getConfiguration('git', root); this._sourceControl.inputBox.visible = config.get('showCommitInput', true);