@@ -567,16 +567,25 @@ function splitSubjectBody(message) {
567
567
return result;
568
568
}
569
569
const capitalizedWordRe = new RegExp('^([A-Z][a-z]*)[^a-zA-Z]');
570
+ const suffixHashCodeRe = new RegExp('\\s?\\(\\s*#[a-zA-Z_0-9]+\\s*\\)$');
570
571
function checkSubject(subject) {
571
572
const errors = [];
572
- if (subject.length > 50) {
573
+ // Tolerate the hash code referring, e.g., to a pull request.
574
+ // These hash codes are usually added automatically by Github and
575
+ // similar services.
576
+ const subjectWoCode = subject.replace(suffixHashCodeRe, '');
577
+ if (subjectWoCode.length > 50) {
573
578
errors.push(`The subject exceeds the limit of 50 characters, got: ${subject.length}`);
574
579
}
575
- const match = capitalizedWordRe.exec(subject );
580
+ const match = capitalizedWordRe.exec(subjectWoCode );
576
581
if (!match) {
577
582
errors.push('The subject must start with a capitalized verb (e.g., "Change").');
578
583
}
579
584
else {
585
+ if (match.length < 2) {
586
+ throw Error('Expected at least one group to match the first capitalized word, ' +
587
+ 'but got none.');
588
+ }
580
589
const word = match[1];
581
590
if (!mostFrequentEnglishVerbs.SET.has(word.toLowerCase())) {
582
591
errors.push('The subject must start in imperative mood with one of the ' +
@@ -586,7 +595,7 @@ function checkSubject(subject) {
586
595
'for a complete list.');
587
596
}
588
597
}
589
- if (subject .endsWith('.')) {
598
+ if (subjectWoCode .endsWith('.')) {
590
599
errors.push("The subject must not end with a dot ('.').");
591
600
}
592
601
return errors;
@@ -8574,7 +8583,10 @@ exports.SET = new Set([
8574
8583
'refactor',
8575
8584
'reorganise',
8576
8585
'reorganize',
8577
- 'restructure'
8586
+ 'restructure',
8587
+ 'unify',
8588
+ 'reword',
8589
+ 'rephrase'
8578
8590
]);
8579
8591
8580
8592
0 commit comments