Skip to content

Instantly share code, notes, and snippets.

@damiancipolat
Created March 12, 2020 03:24
Show Gist options
  • Save damiancipolat/5ab59a618d6a919a4d01cb7e6030b712 to your computer and use it in GitHub Desktop.
Save damiancipolat/5ab59a618d6a919a4d01cb7e6030b712 to your computer and use it in GitHub Desktop.
Bash script to avoid same package.json version to be used in a githook.
#!/bin/bash
set -o nounset
set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
echo "Git repo is at $REPO_ROOT"
SITE_CHANGES=$(git diff origin/develop -- ./package.json | grep version | wc -l)
echo "Detected $SITE_CHANGES changes"
if [ "$SITE_CHANGES" != 2 ]; then
echo "Version was not updated :( Aborting push."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment