Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save petervanderdoes/2877083 to your computer and use it in GitHub Desktop.
Save petervanderdoes/2877083 to your computer and use it in GitHub Desktop.
gitflow hooks and filters for WordPress theme development
#!/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
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment