Skip to content

Commit

Permalink
ci(commitlint): dynamically estimate max header length for pull reque…
Browse files Browse the repository at this point in the history
…st title on squash and merge (#98)
  • Loading branch information
jeffladiray authored Aug 3, 2020
1 parent b8ad4b2 commit 12a1b4e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
// NOTICE: When a github "squash and merge" is performed, github add the PR link in the commit
// message using the format ` (#<PR_ID>)`. Travis provide the target branch of the build,
// so authorizing 4+5 = 9 characters more on master for the max header length should work
// until we reach PR #99999.

let maxHeaderLength = 100;

const prExtrasChars = 9;

const isCommitOnMaster = process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH === 'master';

if (isCommitOnMaster) {
maxHeaderLength += prExtrasChars;
}

module.exports = {
extends: ['@commitlint/config-conventional'],
rules: { 'header-max-length': [2, 'always', 100] },
rules: { 'header-max-length': [2, 'always', maxHeaderLength] },
};

0 comments on commit 12a1b4e

Please sign in to comment.