Skip to content

Commit 01c956c

Browse files
authored
ci(commitlint): dynamically estimate max header length for pull request title on squash and merge (#387)
1 parent 6a46633 commit 01c956c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

commitlint.config.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
// NOTICE: When a github "squash and merge" is performed, github add the PR link in the commit
2+
// message using the format ` (#<PR_ID>)`. Travis provide the target branch of the build,
3+
// so authorizing 4+5 = 9 characters more on master for the max header length should work
4+
// until we reach PR #99999.
5+
6+
let maxHeaderLength = 100;
7+
8+
const prExtrasChars = 9;
9+
10+
const isCommitOnMaster = process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH === 'master';
11+
12+
if (isCommitOnMaster) {
13+
maxHeaderLength += prExtrasChars;
14+
}
15+
116
module.exports = {
217
extends: ['@commitlint/config-conventional'],
3-
rules: { 'header-max-length': [2, 'always', 100] },
18+
rules: { 'header-max-length': [2, 'always', maxHeaderLength] },
419
};

0 commit comments

Comments
 (0)