From 15258ebc5c79e508fc765f93ee69a639524f1003 Mon Sep 17 00:00:00 2001 From: Gleb Buzin Date: Fri, 17 Dec 2021 04:43:34 +0300 Subject: [PATCH] feat: add silentAutoCommit option to not focus scm pane on auto commit (#200) * feat(extension): add silentAutoCommit option to not focus scm pane on auto commit * docs: :globe_with_meridians: added chinese translation for `silentAutoCommit` Co-authored-by: yi_Xu --- README.md | 1 + package.json | 5 +++++ package.nls.json | 1 + package.nls.zh-cn.json | 1 + src/lib/configuration.ts | 1 + src/lib/conventional-commits.ts | 5 ++++- 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a2d2b19..287a7cf 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ You can access VSCode Conventional Commits in two ways: | `conventionalCommits.scopes` | Specify available selections in the `scope` section. | [] | | `conventionalCommits.showEditor` | Control whether the extension should show the commit message as a text document in a separate tab. | false | | `conventionalCommits.showNewVersionNotes` | Control whether the extension should show the new version notes. | true | +| `conventionalCommits.silentAutoCommit` | Control that auto commit should be silent, without focusing source control panel. | false | | `conventionalCommits.editor.keepAfterSave` | Control whether the extension should keep the editor tab open after saving the commit message. | false | ## Commit Workflow diff --git a/package.json b/package.json index c8391fe..844a1cb 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,11 @@ "default": true, "markdownDescription": "%extension.configuration.autoCommit.markdownDescription%" }, + "conventionalCommits.silentAutoCommit": { + "type": "boolean", + "default": false, + "markdownDescription": "%extension.configuration.silentAutoCommit.markdownDescription%" + }, "conventionalCommits.emojiFormat": { "type": "string", "default": "code", diff --git a/package.nls.json b/package.nls.json index 53da7f1..f99256b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -3,6 +3,7 @@ "extension.commands.resetGlobalState": "Conventional Commits: Reset Global State", "extension.commands.showNewVersionNotes": "Conventional Commits: Show Version Notes", "extension.configuration.autoCommit.markdownDescription": "Control whether the extension should commit files after: forming the message or closing the editor tab.\n\nWhen `#git.enableSmartCommit#` enabled and `#git.smartCommitChanges#` was set to `all`, It allows to commit all changes when there are no staged changes.\n\nAnd set `#git.postCommitCommand#` to `sync` to run `git.sync` after commit.", + "extension.configuration.silentAutoCommit.markdownDescription": "Control that auto commit should be silent, without focusing source control panel.", "extension.configuration.emojiFormat.markdownDescription": "Specify which format will be shown in the `gitmoji`.", "extension.configuration.emojiFormat.markdownEnumDescriptions.code": "Display as `:bug:`", "extension.configuration.emojiFormat.markdownEnumDescriptions.emoji": "Display as `🐛`", diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index 0f7d3cb..8b95571 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -2,6 +2,7 @@ "extension.name": "约定式提交", "extension.commands.resetGlobalState": "约定式提交: 重置全局状态", "extension.commands.showNewVersionNotes": "约定式提交: 显示版本提示", + "extension.configuration.silentAutoCommit.markdownDescription": "是否需要静默自动提交。\n\n启用后,自动提交后会自动聚焦到源代码控制面板。", "extension.configuration.autoCommit.markdownDescription": "是否自动提交改动。\n\n当打开 `#git.enableSmartCommit#` 并设置 `#git.smartCommitChanges#` 为 `all` 时,可以在无暂存内容时,自动将所有改动提交。\n\n设置 `#git.postCommitCommand#` 为 `sync` 可以在提交后自动执行 `git.sync`。", "extension.configuration.emojiFormat.markdownDescription": "指定将在 `gitmoji` 中显示的格式。", "extension.configuration.emojiFormat.markdownEnumDescriptions.code": "显示为 `:bug:`", diff --git a/src/lib/configuration.ts b/src/lib/configuration.ts index a4ef81b..5935822 100644 --- a/src/lib/configuration.ts +++ b/src/lib/configuration.ts @@ -12,6 +12,7 @@ export enum EMOJI_FORMAT { export type Configuration = { autoCommit: boolean; + silentAutoCommit: boolean; gitmoji: boolean; emojiFormat: EMOJI_FORMAT; showEditor: boolean; diff --git a/src/lib/conventional-commits.ts b/src/lib/conventional-commits.ts index 8604dc7..7865e10 100644 --- a/src/lib/conventional-commits.ts +++ b/src/lib/conventional-commits.ts @@ -162,12 +162,15 @@ export default function createConventionalCommits() { // 6. switch to scm and put message into message box // or show the entire commit message in a separate tab const showEditor = configuration.get('showEditor'); + const silentAutoCommit = configuration.get('silentAutoCommit'); if (showEditor) { repository.inputBox.value = message; await openMessageInTab(repository); output.info('Show full commit message in a separate tab successfully.'); } else { - vscode.commands.executeCommand('workbench.view.scm'); + if (!silentAutoCommit) { + vscode.commands.executeCommand('workbench.view.scm'); + } repository.inputBox.value = message; output.info(`inputBox.value:\n${repository.inputBox.value}`); }