Skip to content

Instantly share code, notes, and snippets.

@yauh
Created June 3, 2015 13:42
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 yauh/27f412e48e44b732a580 to your computer and use it in GitHub Desktop.
Save yauh/27f412e48e44b732a580 to your computer and use it in GitHub Desktop.
Update git commit count in settings.json
#!/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