Skip to content

Instantly share code, notes, and snippets.

@IObert
Created December 9, 2019 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IObert/f467b4c410d049e4e6799a87296ae74d to your computer and use it in GitHub Desktop.
Save IObert/f467b4c410d049e4e6799a87296ae74d to your computer and use it in GitHub Desktop.
Git pre-commit hook to sync version number in MTA.yaml and package.json
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
new_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
sed -i '' -e "s/^version: .*/version: $new_version/g" mta.yaml
git add mta.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment