commitlint-gitlab-ci
v0.0.4
Published
A small helper utility for using commitlint inside a Gitlab CI file.
Downloads
2,874
Readme
commitlint-gitlab-ci
Beyond a doubt, commitlint is a useful tool for working with verifying a Git history and keeping everything clean, more so when working with semantic-release.
When working with Gitlab, commitlint
has a minor issue when run for the first time or when force push is used. The fix is the following:
if [ "${CI_BUILD_BEFORE_SHA}" = "0000000000000000000000000000000000000000" ]; then
echo "commitlint from HEAD^"
npx commitlint -x @commitlint/config-conventional -f HEAD^
else
echo "commitlint from ${CI_BUILD_BEFORE_SHA}"
br=`git branch -r --contains ${CI_BUILD_BEFORE_SHA}`
if [ ! -n $br ]; then
npx commitlint -x @commitlint/config-conventional -f HEAD^
else
npx commitlint -x @commitlint/config-conventional -f "${CI_BUILD_BEFORE_SHA}"
fi
fi
To make it easier to do the above, this package was created to consolidate it down to a single line:
npx commitlint-gitlab-ci -x @commitlint/config-conventional
Any parameter can be used, this just wraps it around the call the various if
statements needed to work with Gitlab.