public

gitflow hooks and filters for WordPress theme development

  • Download Gist
filter-flow-release-start-version
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/sh
#
# Runs during git flow release start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
VERSION=$1
 
# Implement your script here.
TAGS=`git tag ${VERSION}* -l|wc -l`
if [ "$TAGS" != 0 ]; then
LASTTAG=$(git describe --tags $(git rev-list --tags --max-count=1))
MAJOR=`echo ${LASTTAG} | sed "s/^\([0-9]*\).*/\1/")`
MINOR=`echo ${LASTTAG} | sed "s/[0-9]*\.\([0-9]*\).*/\1/")`
REVISION=`git rev-list $MAJOR.$MINOR --count`
VERSION=$MAJOR.$MINOR.$REVISION
fi
# Return the VERSION
echo ${VERSION}
exit 0
pre-flow-release-start
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/sh
#
# Ran before git flow release start
#
# Positional arguments:
# $1 The version (including the version prefix)
# $2 The origin remote
# $3 The full branch name (including the release prefix)
# $4 The base from which this release is started
#
VERSION=$1
ORIGIN=$2
BRANCH=$3
BASE=$4
 
# Implement your script here.
ROOTDIR=$(git rev-parse --show-toplevel)
 
sed -i 's/^Version:.*/Version: '$VERSION'/' $ROOTDIR/style.css
git commit -a -m "Version bump $VERSION"
 
# To terminate the git-flow action, return a non-zero exit code.
exit 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.