Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: recognise all-caps strings in the subject #134

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

Open
revelt wants to merge 1 commit into commitizen:master
base: master
Choose a base branch
Loading
from revelt:master
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion engine.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,31 @@ var headerLength = function(answers) {
);
};

var isLetter = function(character) {
if (typeof character !== "string" || !character.trim()) {
return false
}
return character.toUpperCase() !== character.toLowerCase();
}

var isUppercaseLetter = function(character) {
if (typeof character !== "string" || !character.trim()) {
return false
}
return character === character.toUpperCase();
}

var maxSummaryLength = function(options, answers) {
return options.maxHeaderWidth - headerLength(answers);
};

var filterSubject = function(subject, disableSubjectLowerCase) {
subject = subject.trim();
if (!disableSubjectLowerCase && subject.charAt(0).toLowerCase() !== subject.charAt(0)) {
if (
!disableSubjectLowerCase &&
subject.charAt(0).toLowerCase() !== subject.charAt(0) &&
(!subject.charAt(1) || !isLetter(subject.charAt(1)) || !isUppercaseLetter(subject.charAt(1)))
) {
subject =
subject.charAt(0).toLowerCase() + subject.slice(1, subject.length);
}
Expand Down
47 changes: 47 additions & 0 deletions engine.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,53 @@ describe('commit message', function() {
)
).to.equal(`${type}(${upperCaseScope}): ${subject}\n\n${body}`);
});
it('all caps subject, disableSubjectLowerCase off', function() {
var allCapsSubject = `XML changes`;
expect(
commitMessage(
{
type,
scope,
subject: allCapsSubject,
body
},
{
...defaultOptions,
disableSubjectLowerCase: false // <---
}
)
).to.equal(`${type}(${scope}): ${allCapsSubject}\n\n${body}`);
});
it('all caps subject, disableSubjectLowerCase on', function() {
var allCapsSubject = `XML changes`;
expect(
commitMessage(
{
type,
scope,
subject: allCapsSubject,
body
},
{
...defaultOptions,
disableSubjectLowerCase: true // <---
}
)
).to.equal(`${type}(${scope}): ${allCapsSubject}\n\n${body}`);
});
it('subject starts with number', function() {
var subjectWithNumber = `2nd iteration`;
expect(
commitMessage(
{
type,
scope,
subject: subjectWithNumber,
body
}
)
).to.equal(`${type}(${scope}): ${subjectWithNumber}\n\n${body}`);
});
it('header and body w/ uppercase subject', function() {
var upperCaseSubject = subject.toLocaleUpperCase();
expect(
Expand Down

AltStyle によって変換されたページ (->オリジナル) /