0.0.4 • Published 3 years ago

commitlint-gitlab-ci v0.0.4

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 years ago

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.

0.0.4

3 years ago

0.0.3

3 years ago