Skip to content

Instantly share code, notes, and snippets.

@IObert IObert/pre-commit
Created Dec 9, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.