Skip to content

Commit

Permalink
feat: ✨ add enums for get value of commitlint for max subject and body
Browse files Browse the repository at this point in the history
add getSubjectMaxLengthEnum() and getBodyMaxLengthEnum() for get value defined on commitlint rules

vivaxy#293
  • Loading branch information
gabolera committed Sep 28, 2023
1 parent 1c209fa commit 113359d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 0 additions & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"extension.configuration.showEditor.markdownDescription": "Control whether the extension should show the commit message as a text document in a separate tab.",
"extension.configuration.showNewVersionNotes.markdownDescription": "Control whether the extension should show the new version notes.",
"extension.configuration.editor.keepAfterSave.markdownDescription": "Control whether the extension should keep the editor tab open, after saving the commit message.",
"extension.configuration.commitMaxLength.subject.markdownDescription": "Control the recommended maximum size displayed in the subject on commit message.",
"extension.configuration.commitMaxLength.body.markdownDescription": "Control the recommended maximum size displayed in the body on commit message.",
"extension.sources.repositoryNotFoundInPath": "Repository not found in path: ",
"extension.sources.repositoriesEmpty": "Please open a repository.",
"extension.sources.promptRepositoryPlaceholder": "Choose a repository.",
Expand Down
2 changes: 0 additions & 2 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"extension.configuration.showEditor.markdownDescription": "是否需要在新标签页用文本编辑器展示提交信息",
"extension.configuration.showNewVersionNotes.markdownDescription": "是否需要显示新版本说明。",
"extension.configuration.editor.keepAfterSave.markdownDescription": "是否需要在保存提交消息后保持编辑状态。",
"extension.configuration.commitMaxLength.subject.markdownDescription": "在“描述”输入框下方显示建议的最大长度值。",
"extension.configuration.commitMaxLength.body.markdownDescription": "在“正文”输入框下方显示建议的最大长度值。",
"extension.sources.repositoryNotFoundInPath": "以下路径中未找到仓库:",
"extension.sources.repositoriesEmpty": "请打开一个仓库。",
"extension.sources.promptRepositoryPlaceholder": "请选择一个仓库。",
Expand Down
8 changes: 8 additions & 0 deletions src/lib/commitlint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class Commitlint {
return this.getEnum('type-enum');
}

getSubjectMaxLengthEnum() {
return this.getEnum('subject-max-length');
}

getBodyMaxLengthEnum() {
return this.getEnum('body-max-length');
}

getScopeEnum() {
return this.getEnum('scope-enum');
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export type Configuration = {
promptCI: boolean;
showNewVersionNotes: boolean;
'editor.keepAfterSave': boolean;
'commitMaxLength.subject': number;
'commitMaxLength.body': number;
};

export function getConfiguration() {
Expand Down
9 changes: 4 additions & 5 deletions src/lib/prompts/prompt-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import createSimpleQuickPick, { confirmButton } from './quick-pick';
import localize from '../localize';
import * as output from '../output';
import { CommitStore } from '../commit-store';
import commitlint from '../commitlint';

const storeCommit = CommitStore.initialize();

Expand Down Expand Up @@ -125,7 +126,7 @@ function createInputBox({
reject(e);
}
});
input.onDidTriggerButton(function (e) {
input.onDidTriggerButton(function (e: any) {
if (e === confirmButton) {
try {
if (input.validationMessage) {
Expand Down Expand Up @@ -287,10 +288,8 @@ function promptMessageMaxLength({
placeholder: string;
name?: string;
}) {
const subjectMax: number = configuration.get<number>(
'commitMaxLength.subject',
);
const bodyMax: number = configuration.get<number>('commitMaxLength.body');
const subjectMax: number = Number(commitlint.getSubjectMaxLengthEnum());
const bodyMax: number = Number(commitlint.getBodyMaxLengthEnum());
if (name && name === 'subject') {
const type = storeCommit.get('type');
const scope = storeCommit.get('scope');
Expand Down

0 comments on commit 113359d

Please sign in to comment.