提交 eb6025ec 编写于 作者: J Joao Moreno

git.postCommitCommand

fixes #62058
上级 b896eff2
......@@ -1096,6 +1096,21 @@
"default": true,
"description": "%config.promptToSaveFilesBeforeCommit%"
},
"git.postCommitCommand": {
"type": "string",
"enum": [
"none",
"push",
"sync"
],
"enumDescriptions": [
"%config.postCommitCommand.none%",
"%config.postCommitCommand.push%",
"%config.postCommitCommand.sync%"
],
"markdownDescription": "%config.postCommitCommand%",
"default": "none"
},
"git.showInlineOpenFileAction": {
"type": "boolean",
"default": true,
......@@ -1353,4 +1368,4 @@
"@types/which": "^1.0.28",
"mocha": "^3.2.0"
}
}
}
\ No newline at end of file
......@@ -88,6 +88,10 @@
"config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.",
"config.decorations.enabled": "Controls whether Git contributes colors and badges to the explorer and the open editors view.",
"config.promptToSaveFilesBeforeCommit": "Controls whether Git should check for unsaved files before committing.",
"config.postCommitCommand": "Runs a git command after a successful commit.",
"config.postCommitCommand.none": "Don't run any command after a commit.",
"config.postCommitCommand.push": "Run 'Git Push' after a successful commit.",
"config.postCommitCommand.sync": "Run 'Git Sync' after a successful commit.",
"config.showInlineOpenFileAction": "Controls whether to show an inline Open File action in the Git changes view.",
"config.showPushSuccessNotification": "Controls whether to show a notification when a push is successful.",
"config.inputValidation": "Controls when to show commit message input validation.",
......
......@@ -163,6 +163,7 @@ enum PushType {
interface PushOptions {
pushType: PushType;
forcePush?: boolean;
silent?: boolean;
}
export class CommandCenter {
......@@ -1225,6 +1226,17 @@ export class CommandCenter {
await repository.commit(message, opts);
const postCommitCommand = config.get<'none' | 'push' | 'sync'>('postCommitCommand');
switch (postCommitCommand) {
case 'push':
await this._push(repository, { pushType: PushType.Push, silent: true });
break;
case 'sync':
await this.sync(repository);
break;
}
return true;
}
......@@ -1615,7 +1627,9 @@ export class CommandCenter {
const remotes = repository.remotes;
if (remotes.length === 0) {
window.showWarningMessage(localize('no remotes to push', "Your repository has no remotes configured to push to."));
if (!pushOptions.silent) {
window.showWarningMessage(localize('no remotes to push', "Your repository has no remotes configured to push to."));
}
return;
}
......@@ -1652,7 +1666,9 @@ export class CommandCenter {
}
if (!repository.HEAD || !repository.HEAD.name) {
window.showWarningMessage(localize('nobranch', "Please check out a branch to push to a remote."));
if (!pushOptions.silent) {
window.showWarningMessage(localize('nobranch', "Please check out a branch to push to a remote."));
}
return;
}
......@@ -1664,6 +1680,10 @@ export class CommandCenter {
throw err;
}
if (pushOptions.silent) {
return;
}
const branchName = repository.HEAD.name;
const message = localize('confirm publish branch', "The branch '{0}' has no upstream branch. Would you like to publish this branch?", branchName);
const yes = localize('ok', "OK");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册