Last Updated: February 25, 2016
·
379
· dinks

Git Version tags for Gem changes

Say the gem is abcd

The git hook will be

File: .git/hooks/post-commit
#! /bin/bash
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/lib/abcd/version.rb | grep '^\+.*VERSION =' | sed -E 's/[^0-9\.]//g'`

if [ "$version" != "" ]; then
    git tag -a "v$version" -m "`git log -1 --format=%s`"
    echo "Created a new tag, v$version"
fi

Inspired from https://coderwall.com/p/mk18zq :)