Skip to content

Commit 1b309ef

Browse files
authored
Git - Commit keyboard shortcut to honor the post commit command setting (microsoft#157619)
Commit keyboard shortcut to honor the post commit command setting (microsoft#157617)
1 parent 0fca72b commit 1b309ef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

extensions/git/src/repository.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,6 @@ export class Repository implements Disposable {
914914
const root = Uri.file(repository.root);
915915
this._sourceControl = scm.createSourceControl('git', 'Git', root);
916916

917-
this._sourceControl.acceptInputCommand = { command: 'git.commit', title: localize('commit', "Commit"), arguments: [this._sourceControl] };
918917
this._sourceControl.quickDiffProvider = this;
919918
this._sourceControl.inputBox.validateInput = this.validateInput.bind(this);
920919
this.disposables.push(this._sourceControl);
@@ -951,6 +950,17 @@ export class Repository implements Disposable {
951950
|| e.affectsConfiguration('git.showActionButton', root)
952951
)(this.updateModelState, this, this.disposables);
953952

953+
const updateInputBoxAcceptInputCommand = () => {
954+
const config = workspace.getConfiguration('git', root);
955+
const postCommitCommand = config.get<string>('postCommitCommand');
956+
const postCommitCommandArg = postCommitCommand === 'push' || postCommitCommand === 'sync' ? `git.${postCommitCommand}` : '';
957+
this._sourceControl.acceptInputCommand = { command: 'git.commit', title: localize('commit', "Commit"), arguments: [this._sourceControl, postCommitCommandArg] };
958+
};
959+
960+
const onConfigListenerForPostCommitCommand = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.postCommitCommand', root));
961+
onConfigListenerForPostCommitCommand(updateInputBoxAcceptInputCommand, this, this.disposables);
962+
updateInputBoxAcceptInputCommand();
963+
954964
const updateInputBoxVisibility = () => {
955965
const config = workspace.getConfiguration('git', root);
956966
this._sourceControl.inputBox.visible = config.get<boolean>('showCommitInput', true);

0 commit comments

Comments
 (0)