Skip to content

Commit 8d22319

Browse files
authored
Allow Infinity as line limit (#137)
GitHub started reflowing the descriptions of the pull requests, so we want often to disable the check in the pull requests.
1 parent f3b9cec commit 8d22319

File tree

8 files changed

+117
-77
lines changed

8 files changed

+117
-77
lines changed

.github/workflows/build-and-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
with:
2828
additional-verbs: 'chrusimusi, unit-test'
2929
path-to-additional-verbs: src/additional-verbs.txt
30+
max-body-line-length: 'Infinity'
3031

3132
# test-pr-commits:
3233
# runs-on: ubuntu-latest
@@ -44,3 +45,4 @@ jobs:
4445
- uses: ./
4546
with:
4647
allow-one-liners: 'true'
48+
max-body-line-length: 'Infinity'

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ You can change the imposed maximum subject length by setting the flag `max-subje
174174
max-subject-line-length: '100'
175175
```
176176

177+
If you want to disable the limit, set it to `Infinity`.
178+
177179
## Custom line length on the body
178180

179181
Similar to the subject line, for terminals and monospaced GUIs it is a good practice to limit the line length of the body to 72 characters.
@@ -190,6 +192,8 @@ You can change the imposed maximum line length by setting the flag `max-body-lin
190192
max-body-line-length: '100'
191193
```
192194

195+
If you want to disable the limit, set it to `Infinity`.
196+
193197
## Skip Body Check
194198

195199
For some repositories only the subject matters while the body is allowed to be free-form.

dist/index.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -29058,6 +29058,25 @@ class MaybeInputs {
2905829058
}
2905929059
}
2906029060
exports.MaybeInputs = MaybeInputs;
29061+
const infLiteralSet = new Set([
29062+
'inf',
29063+
'infty',
29064+
'infinity',
29065+
'-inf',
29066+
'-infty',
29067+
'-infinity',
29068+
]);
29069+
/**
29070+
* Parse the `text` as either an integer or `Infinity`.
29071+
*
29072+
* If the `text` could not be parsed, return a `NaN`.
29073+
*/
29074+
function parseIntOrInfinity(text) {
29075+
if (infLiteralSet.has(text.toLowerCase())) {
29076+
return Infinity;
29077+
}
29078+
return parseInt(text, 10);
29079+
}
2906129080
function parseInputs(rawInputs) {
2906229081
const { additionalVerbsInput = '', pathToAdditionalVerbsInput = '', allowOneLinersInput = '', maxSubjectLengthInput = '', maxBodyLineLengthInput = '', enforceSignOffInput = '', validatePullRequestCommitsInput = '', skipBodyCheckInput = '', ignoreMergeCommitsInput = '', ignorePatternsInput = '', } = rawInputs;
2906329082
const additionalVerbs = new Set();
@@ -29086,14 +29105,14 @@ function parseInputs(rawInputs) {
2908629105
}
2908729106
const maxSubjectLength = !maxSubjectLengthInput
2908829107
? 50
29089-
: parseInt(maxSubjectLengthInput, 10);
29108+
: parseIntOrInfinity(maxSubjectLengthInput);
2909029109
if (Number.isNaN(maxSubjectLength)) {
2909129110
return new MaybeInputs(null, 'Unexpected value for max-subject-line-length. ' +
2909229111
`Expected a number or nothing, got ${maxSubjectLengthInput}`);
2909329112
}
2909429113
const maxBodyLineLength = !maxBodyLineLengthInput
2909529114
? 72
29096-
: parseInt(maxBodyLineLengthInput, 10);
29115+
: parseIntOrInfinity(maxBodyLineLengthInput);
2909729116
if (Number.isNaN(maxBodyLineLength)) {
2909829117
return new MaybeInputs(null, 'Unexpected value for max-body-line-length. ' +
2909929118
`Expected a number or nothing, got ${maxBodyLineLengthInput}`);

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/input.test.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ it('parses the inputs.', () => {
4343
ignorePatternsInput: `
4444
^Some pattern$
4545
Another pattern
46-
`
46+
`,
4747
});
4848

4949
expect(maybeInputs.error).toBeNull();
@@ -52,7 +52,7 @@ it('parses the inputs.', () => {
5252
expect(inputs.hasAdditionalVerbsInput).toBeTruthy();
5353
expect(inputs.pathToAdditionalVerbs).toEqual(pathToVerbs);
5454
expect(inputs.additionalVerbs).toEqual(
55-
new Set<string>(['rewrap', 'table', 'integrate', 'analyze'])
55+
new Set<string>(['rewrap', 'table', 'integrate', 'analyze']),
5656
);
5757
expect(inputs.allowOneLiners).toBeTruthy();
5858
expect(inputs.maxSubjectLength).toEqual(90);
@@ -61,8 +61,18 @@ it('parses the inputs.', () => {
6161
expect(inputs.validatePullRequestCommits).toBeTruthy();
6262
expect(inputs.skipBodyCheck).toBeTruthy();
6363
expect(inputs.ignoreMergeCommits).toBeFalsy();
64-
expect(inputs.ignorePatterns).toEqual([
65-
/^Some pattern$/,
66-
/Another pattern/
67-
]);
64+
expect(inputs.ignorePatterns).toEqual([/^Some pattern$/, /Another pattern/]);
65+
});
66+
67+
it('parses the Infinity limits.', () => {
68+
const maybeInputs = input.parseInputs({
69+
maxSubjectLengthInput: 'Infinity',
70+
maxBodyLineLengthInput: 'Infinity',
71+
});
72+
73+
expect(maybeInputs.error).toBeNull();
74+
75+
const inputs = maybeInputs.mustInputs();
76+
expect(inputs.maxSubjectLength).toEqual(Infinity);
77+
expect(inputs.maxBodyLineLength).toEqual(Infinity);
6878
});

0 commit comments

Comments
 (0)