Last active
June 17, 2019 10:14
-
-
Save nealeu/455eeec0b0f58059596e8d2d3a00bf96 to your computer and use it in GitHub Desktop.
Check commits contain reference to tickets on Bitbucket/Shippable branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipelines: | |
branches: | |
*: | |
- step: | |
script: | |
- npm ci | |
- npm run lint | |
- npm test | |
# == Check that all commits since the base branch (dev) contain ACME- for ticket reference == | |
# Fetch the merge base for our project | |
- git fetch origin dev:dev | |
- > | |
echo "-- Checking ACME- prefix on commits --" | |
&& [[ `git log --oneline dev.. | grep -v 'ACME-' | wc -l` -eq 0 ]] | |
&& echo "Passed" | |
|| (echo "Failed for the following commits:" | |
&& git log --oneline dev.. | grep -v 'ACME-' | |
&& [[ 0 -eq 1 ]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assume that the original repository is a shallow clone (e.g. Bitbucket Pipelines does a --shallow 50 clone of the branch), so we add
git fetch origin dev:dev
to fetch the merge base (in our case the dev branch) to the local refdev
.