Skip to content

Commit

Permalink
feat(body): ✨ add option to remove body prompt
Browse files Browse the repository at this point in the history
Ref: #107
  • Loading branch information
yi-Xu-0100 committed Apr 2, 2021
1 parent cde052c commit a199912
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ You can access VSCode Conventional Commits in two ways:
| `conventionalCommits.emojiFormat` | Specifies which format will be shown in the `gitmoji`. | code |
| `conventionalCommits.gitmoji` | Controls whether the extension should prompt for a `gitmoji`. | true |
| `conventionalCommits.lineBreak` | Specifies which word will be treat as line breaks in the `body`.<br>Blank means no line breaks. | "" |
| `conventionalCommits.promptBody` | Controls whether the extension should prompt for the `Body` section. | true |
| `conventionalCommits.promptScopes` | Controls whether the extension should prompt for the `scope` section. | true |
| `conventionalCommits.scopes` | Specifies available selections in the `scope` section. | [] |
| `conventionalCommits.showEditor` | Show the commit message as a text document in a separate tab. | false |
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
"default": "",
"markdownDescription": "%extension.configuration.properties.conventionalCommits.lineBreak.markdownDescription%"
},
"conventionalCommits.promptBody": {
"type": "boolean",
"default": true,
"markdownDescription": "%extension.configuration.properties.conventionalCommits.promptBody.markdownDescription%"
},
"conventionalCommits.promptScopes": {
"type": "boolean",
"default": true,
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"extension.configuration.properties.conventionalCommits.emojiFormat.markdownEnumDescriptions.emoji": "Display as `🐛`",
"extension.configuration.properties.conventionalCommits.gitmoji.markdownDescription": "Controls whether the extension should prompt for a `gitmoji`.",
"extension.configuration.properties.conventionalCommits.lineBreak.markdownDescription": "Specifies which word will be treat as line breaks in the `body`.\n\nBlank means no line breaks.",
"extension.configuration.properties.conventionalCommits.promptBody.markdownDescription": "Controls whether the extension should prompt for the `body` section.",
"extension.configuration.properties.conventionalCommits.promptScopes.markdownDescription": "Controls whether the extension should prompt for the `scope` section.",
"extension.configuration.properties.conventionalCommits.scopes.markdownDescription": "Specifies available selections in the `scope` section.",
"extension.configuration.properties.conventionalCommits.showEditor.markdownDescription": "Show the commit message as a text document in a separate tab.",
Expand Down
1 change: 1 addition & 0 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"extension.configuration.properties.conventionalCommits.emojiFormat.markdownEnumDescriptions.emoji": "显示为 `🐛`",
"extension.configuration.properties.conventionalCommits.gitmoji.markdownDescription": "是否需要填写 `gitmoji`。",
"extension.configuration.properties.conventionalCommits.lineBreak.markdownDescription": "指定哪种换行标识符应该被在 `body` 中识别。\n\n留空表示不换行。",
"extension.configuration.properties.conventionalCommits.promptBody.markdownDescription": "是否需要填写 `body`。",
"extension.configuration.properties.conventionalCommits.promptScopes.markdownDescription": "是否需要填写 `scope`。",
"extension.configuration.properties.conventionalCommits.scopes.markdownDescription": "指定 `scope` 中的可选项。",
"extension.configuration.properties.conventionalCommits.showEditor.markdownDescription": "在新标签页用文本编辑器展示提交信息",
Expand Down
1 change: 1 addition & 0 deletions src/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Configuration = {
scopes: string[];
lineBreak: string;
promptScopes: boolean;
promptBody: boolean;
};

export function getConfiguration() {
Expand Down
1 change: 1 addition & 0 deletions src/lib/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default function createConventionalCommits() {
),
lineBreak: configuration.get<string>('lineBreak'),
promptScopes: configuration.get<boolean>('promptScopes'),
promptBody: configuration.get<boolean>('promptBody'),
});
output.info(`messageJSON:\n${JSON.stringify(commitMessage, null, 2)}`);
const message = serialize(commitMessage);
Expand Down
5 changes: 4 additions & 1 deletion src/lib/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ export default async function prompts({
emojiFormat,
lineBreak,
promptScopes,
promptBody,
}: {
gitmoji: boolean;
showEditor: boolean;
emojiFormat: configuration.EMOJI_FORMAT;
lineBreak: string;
promptScopes: boolean;
promptBody: boolean;
}): Promise<CommitMessage> {
const commitMessage = new CommitMessage();
const conventionalCommitsTypes: ConventionalCommitsTypes = getConventionalCommitsTypesByLocale(
Expand Down Expand Up @@ -270,7 +272,8 @@ export default async function prompts({
return false;
} else if (
showEditor &&
(question.name === 'body' || question.name === 'footer')
((!promptBody && question.name === 'body') ||
question.name === 'footer')
) {
return false;
} else {
Expand Down

0 comments on commit a199912

Please sign in to comment.