diff --git a/README.md b/README.md index 21fb237c7..e0f9d40d2 100644 --- a/README.md +++ b/README.md @@ -56,19 +56,20 @@ feat(ui): Add `Button` component. ```yml with: - # Configure which types are allowed. + # Configure which types are allowed (newline delimited). # Default: https://github.com/commitizen/conventional-commit-types types: | fix feat - # Configure which scopes are allowed. + # Configure which scopes are allowed (newline delimited). scopes: | core ui # Configure that a scope must always be provided. requireScope: true - # Configure which scopes are disallowed in PR titles. For instance by setting - # the value below, `chore(release): ...` and `ci(e2e,release): ...` will be rejected. + # Configure which scopes (newline delimited) are disallowed in PR + # titles. For instance by setting # the value below, `chore(release): + # ...` and `ci(e2e,release): ...` will be rejected. disallowScopes: | release # Configure additional validation for the subject based on a regex. @@ -83,8 +84,8 @@ feat(ui): Add `Button` component. doesn't start with an uppercase character. # If you use GitHub Enterprise, you can set this to the URL of your server githubBaseUrl: https://github.myorg.com/api/v3 - # If the PR contains one of these labels, the validation is skipped. - # Multiple labels can be separated by newlines. + # 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. ignoreLabels: | @@ -180,4 +181,4 @@ When using "Squash and merge" on a PR with only one commit, GitHub will suggest # Related to `validateSingleCommit` you can opt-in to validate that the PR # title matches a single commit to avoid confusion. validateSingleCommitMatchesPrTitle: true -``` \ No newline at end of file +``` diff --git a/action.yml b/action.yml index ab3323ca4..9a51aa103 100644 --- a/action.yml +++ b/action.yml @@ -9,16 +9,16 @@ branding: color: 'green' inputs: types: - description: "Provide custom types if you don't want the default ones from https://www.conventionalcommits.org" + description: "Provide custom types (newline delimited) if you don't want the default ones from https://www.conventionalcommits.org." required: false scopes: - description: "Configure which scopes are allowed." + description: "Configure which scopes are allowed (newline delimited)." required: false requireScope: description: "Configure that a scope must always be provided." required: false disallowScopes: - description: 'Configure which scopes are disallowed in PR titles.' + description: 'Configure which scopes are disallowed in PR titles (newline delimited).' required: false subjectPattern: 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: description: "If you use Github Enterprise, you can set this to the URL of your server (e.g. https://github.myorg.com/api/v3)" required: false ignoreLabels: - 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." + 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." required: false headerPattern: 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" diff --git a/src/ConfigParser.js b/src/ConfigParser.js index c307c528a..b0f9c63e0 100644 --- a/src/ConfigParser.js +++ b/src/ConfigParser.js @@ -1,4 +1,4 @@ -const ENUM_SPLIT_REGEX = /[,\s]\s*/; +const ENUM_SPLIT_REGEX = /\n/; module.exports = { parseEnum(input) { diff --git a/src/ConfigParser.test.js b/src/ConfigParser.test.js index 0de771861..8eb28cc67 100644 --- a/src/ConfigParser.test.js +++ b/src/ConfigParser.test.js @@ -1,17 +1,8 @@ const ConfigParser = require('./ConfigParser'); describe('parseEnum', () => { - it('parses commas', () => { - expect(ConfigParser.parseEnum('one, two,three, \nfour ')).toEqual([ - 'one', - 'two', - 'three', - 'four' - ]); - }); - - it('parses white space', () => { - expect(ConfigParser.parseEnum('one two\nthree \n\rfour')).toEqual([ + it('parses newline-delimited lists, trimming whitespace', () => { + expect(ConfigParser.parseEnum('one \ntwo \nthree \r\nfour')).toEqual([ 'one', 'two', 'three',