Skip to content

Commit

Permalink
feat(footer): ✨ add option to remove footer prompt
Browse files Browse the repository at this point in the history
Fix `Body` to `body` in README.

Closes: #107
  • Loading branch information
yi-Xu-0100 committed Apr 2, 2021
1 parent a199912 commit 46fc717
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ 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.promptBody` | Controls whether the extension should prompt for the `body` section. | true |
| `conventionalCommits.promptFooter` | Controls whether the extension should prompt for the `footer` 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 @@ -91,6 +91,11 @@
"default": true,
"markdownDescription": "%extension.configuration.properties.conventionalCommits.promptBody.markdownDescription%"
},
"conventionalCommits.promptFooter": {
"type": "boolean",
"default": true,
"markdownDescription": "%extension.configuration.properties.conventionalCommits.promptFooter.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 @@ -7,6 +7,7 @@
"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.promptFooter.markdownDescription": "Controls whether the extension should prompt for the `footer` 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 @@ -7,6 +7,7 @@
"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.promptFooter.markdownDescription": "是否需要填写 `footer`。",
"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 @@ -19,6 +19,7 @@ export type Configuration = {
lineBreak: string;
promptScopes: boolean;
promptBody: boolean;
promptFooter: 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 @@ -176,6 +176,7 @@ export default function createConventionalCommits() {
lineBreak: configuration.get<string>('lineBreak'),
promptScopes: configuration.get<boolean>('promptScopes'),
promptBody: configuration.get<boolean>('promptBody'),
promptFooter: configuration.get<boolean>('promptFooter'),
});
output.info(`messageJSON:\n${JSON.stringify(commitMessage, null, 2)}`);
const message = serialize(commitMessage);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ export default async function prompts({
lineBreak,
promptScopes,
promptBody,
promptFooter,
}: {
gitmoji: boolean;
showEditor: boolean;
emojiFormat: configuration.EMOJI_FORMAT;
lineBreak: string;
promptScopes: boolean;
promptBody: boolean;
promptFooter: boolean;
}): Promise<CommitMessage> {
const commitMessage = new CommitMessage();
const conventionalCommitsTypes: ConventionalCommitsTypes = getConventionalCommitsTypesByLocale(
Expand Down Expand Up @@ -273,7 +275,7 @@ export default async function prompts({
} else if (
showEditor &&
((!promptBody && question.name === 'body') ||
question.name === 'footer')
(!promptFooter && question.name === 'footer'))
) {
return false;
} else {
Expand Down

0 comments on commit 46fc717

Please sign in to comment.