Skip to content

Instantly share code, notes, and snippets.

@nealeu
Last active June 17, 2019 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nealeu/455eeec0b0f58059596e8d2d3a00bf96 to your computer and use it in GitHub Desktop.
Save nealeu/455eeec0b0f58059596e8d2d3a00bf96 to your computer and use it in GitHub Desktop.
Check commits contain reference to tickets on Bitbucket/Shippable branch
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 ]])
@nealeu
Copy link
Author

nealeu commented Jun 17, 2019

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 ref dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment