Created
June 3, 2015 13:42
-
-
Save yauh/27f412e48e44b732a580 to your computer and use it in GitHub Desktop.
Update git commit count in settings.json
This file contains hidden or 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
#!/bin/bash | |
# update-commit-setting.sh | |
# Usage: `update-commit-setting.sh [branch] [settings-file]` | |
BRANCH=${1:-'master'} | |
SETTINGS=${2:-'app/settings.json'} | |
BUILDNUMBER=$(expr $(git rev-list $BRANCH --count) - $(git rev-list HEAD..$BRANCH --count)) | |
echo "Updating build number in $SETTINGS to $BUILDNUMBER using branch '$BRANCH'." | |
sed "s/\"git-commit-count\": [0-9]*/\"git-commit-count\": $BUILDNUMBER/g" $SETTINGS > tmp.json | |
mv tmp.json $SETTINGS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment