Skip to content

Commit

Permalink
feat!: Enum options need to be newline delimited (to allow whitespace…
Browse files Browse the repository at this point in the history
… within them) (#205)
  • Loading branch information
jszwedko authored Oct 11, 2022
1 parent b314c1b commit c906fe1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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: |
Expand Down Expand Up @@ -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
```
```
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigParser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ENUM_SPLIT_REGEX = /[,\s]\s*/;
const ENUM_SPLIT_REGEX = /\n/;

module.exports = {
parseEnum(input) {
Expand Down
13 changes: 2 additions & 11 deletions src/ConfigParser.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit c906fe1

Please sign in to comment.