Skip to content

Instantly share code, notes, and snippets.

@canassa
Created December 11, 2013 19:05
Show Gist options
  • Save canassa/7916413 to your computer and use it in GitHub Desktop.
Save canassa/7916413 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Runs during git flow hotfix start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
# version is necessary
#
# The following variables are available as they are exported by git-flow:
#
# MASTER_BRANCH - The branch defined as Master
# DEVELOP_BRANCH - The branch defined as Develop
$version = ARGV[0]
if $version.nil?
last_tag_rev = `git rev-list --tags --max-count=1`.strip
last_tag_name = `git describe --tags #{last_tag_rev}`.strip
major, minor, hotfix = last_tag_name.split('.').map(&:to_i)
$version = "%d.%d.%d" % [major, minor, hotfix + 1]
end
puts $version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment