-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: failing sentence-case for subjects with slashes #574
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,16 @@ export default (parsed, when, value) => { | |
return check; | ||
}); | ||
|
||
// Scopes may contain slash-delimiters to separate them and mark them as individual segments. | ||
// This means that each of these segments should be tested separately with `ensure`. | ||
const delimiters = /(\/|\\)/g; | ||
const scopeSegments = scope.split(delimiters); | ||
|
||
const result = checks.some(check => { | ||
const r = ensure.case(scope, check.case); | ||
const r = scopeSegments.every( | ||
segment => delimiters.test(segment) || ensure.case(segment, check.case) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to check if the segment here is the delimiter itself. But I think this looks pretty ok! |
||
); | ||
|
||
return negated(check.when) ? !r : r; | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,3 +308,17 @@ test('with uppercase scope should fail for "never [uppercase, lowercase]"', asyn | |
const expected = false; | ||
t.is(actual, expected); | ||
}); | ||
|
||
test('with slash in scope should succeed for "always pascal-case"', async t => { | ||
const commit = await parse('feat(Modules/Graph): add Pie Chart'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the full commit described from #291, instead of |
||
const [actual] = scopeCase(commit, 'always', 'pascal-case'); | ||
const expected = true; | ||
t.is(actual, expected); | ||
}); | ||
|
||
test('with slash in subject should succeed for "always sentence case"', async t => { | ||
const commit = await parse('chore: Update @angular/core'); | ||
const [actual] = scopeCase(commit, 'always', 'sentencecase'); | ||
const expected = true; | ||
t.is(actual, expected); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is moved to the
scope-case
rule.