Skip to content

Commit c906fe1

Browse files
authored
feat!: Enum options need to be newline delimited (to allow whitespace within them) (#205)
1 parent b314c1b commit c906fe1

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ feat(ui): Add `Button` component.
5656

5757
```yml
5858
with:
59-
# Configure which types are allowed.
59+
# Configure which types are allowed (newline delimited).
6060
# Default: https://github.com/commitizen/conventional-commit-types
6161
types: |
6262
fix
6363
feat
64-
# Configure which scopes are allowed.
64+
# Configure which scopes are allowed (newline delimited).
6565
scopes: |
6666
core
6767
ui
6868
# Configure that a scope must always be provided.
6969
requireScope: true
70-
# Configure which scopes are disallowed in PR titles. For instance by setting
71-
# the value below, `chore(release): ...` and `ci(e2e,release): ...` will be rejected.
70+
# Configure which scopes (newline delimited) are disallowed in PR
71+
# titles. For instance by setting # the value below, `chore(release):
72+
# ...` and `ci(e2e,release): ...` will be rejected.
7273
disallowScopes: |
7374
release
7475
# Configure additional validation for the subject based on a regex.
@@ -83,8 +84,8 @@ feat(ui): Add `Button` component.
8384
doesn't start with an uppercase character.
8485
# If you use GitHub Enterprise, you can set this to the URL of your server
8586
githubBaseUrl: https://github.myorg.com/api/v3
86-
# If the PR contains one of these labels, the validation is skipped.
87-
# Multiple labels can be separated by newlines.
87+
# If the PR contains one of these labels (newline delimited), the
88+
# validation is skipped.
8889
# If you want to rerun the validation when labels change, you might want
8990
# to use the `labeled` and `unlabeled` event triggers in your workflow.
9091
ignoreLabels: |
@@ -180,4 +181,4 @@ When using "Squash and merge" on a PR with only one commit, GitHub will suggest
180181
# Related to `validateSingleCommit` you can opt-in to validate that the PR
181182
# title matches a single commit to avoid confusion.
182183
validateSingleCommitMatchesPrTitle: true
183-
```
184+
```

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ branding:
99
color: 'green'
1010
inputs:
1111
types:
12-
description: "Provide custom types if you don't want the default ones from https://www.conventionalcommits.org"
12+
description: "Provide custom types (newline delimited) if you don't want the default ones from https://www.conventionalcommits.org."
1313
required: false
1414
scopes:
15-
description: "Configure which scopes are allowed."
15+
description: "Configure which scopes are allowed (newline delimited)."
1616
required: false
1717
requireScope:
1818
description: "Configure that a scope must always be provided."
1919
required: false
2020
disallowScopes:
21-
description: 'Configure which scopes are disallowed in PR titles.'
21+
description: 'Configure which scopes are disallowed in PR titles (newline delimited).'
2222
required: false
2323
subjectPattern:
2424
description: "Configure additional validation for the subject based on a regex. E.g. '^(?![A-Z]).+$' ensures the subject doesn't start with an uppercase character."
@@ -36,7 +36,7 @@ inputs:
3636
description: "If you use Github Enterprise, you can set this to the URL of your server (e.g. https://github.myorg.com/api/v3)"
3737
required: false
3838
ignoreLabels:
39-
description: "If the PR contains one of these labels, the validation is skipped. Multiple labels can be separated by newlines. If you want to rerun the validation when labels change, you might want to use the `labeled` and `unlabeled` event triggers in your workflow."
39+
description: "If the PR contains one of these labels (newline delimited), the validation is skipped. If you want to rerun the validation when labels change, you might want to use the `labeled` and `unlabeled` event triggers in your workflow."
4040
required: false
4141
headerPattern:
4242
description: "If you're using a format for the PR title that differs from the traditional Conventional Commits spec, you can use this to customize the parsing of the type, scope and subject. The `headerPattern` should contain a regex where the capturing groups in parentheses correspond to the parts listed in `headerPatternCorrespondence`. For more details see: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern"

src/ConfigParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const ENUM_SPLIT_REGEX = /[,\s]\s*/;
1+
const ENUM_SPLIT_REGEX = /\n/;
22

33
module.exports = {
44
parseEnum(input) {

src/ConfigParser.test.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
const ConfigParser = require('./ConfigParser');
22

33
describe('parseEnum', () => {
4-
it('parses commas', () => {
5-
expect(ConfigParser.parseEnum('one, two,three, \nfour ')).toEqual([
6-
'one',
7-
'two',
8-
'three',
9-
'four'
10-
]);
11-
});
12-
13-
it('parses white space', () => {
14-
expect(ConfigParser.parseEnum('one two\nthree \n\rfour')).toEqual([
4+
it('parses newline-delimited lists, trimming whitespace', () => {
5+
expect(ConfigParser.parseEnum('one \ntwo \nthree \r\nfour')).toEqual([
156
'one',
167
'two',
178
'three',

0 commit comments

Comments
 (0)