Skip to content

Instantly share code, notes, and snippets.

@osheroff
Created May 11, 2011 19:01
Show Gist options
  • Save osheroff/967075 to your computer and use it in GitHub Desktop.
Save osheroff/967075 to your computer and use it in GitHub Desktop.
git-prodtag
#!/bin/bash
if [[ `git branch | grep '*' | awk '{print $2}'` != 'production' ]] ; then
echo "Only on checked out production branch, plz"
exit
fi
git fetch --tags origin
RUBY=$(cat <<endruby
require 'pp'
tags = []
STDIN.lines.each do |l|
next unless l =~ /^v(\d+\.\d+\.\d+)/
tags << l
end
tags = tags.map { |t| t.gsub('v', '').split('.').map(&:to_i) }
sorted = tags.sort_by { |t|
-(t[0] * 1_000_000 + t[1] * 1_000 + t[2])
}
current = sorted[0]
puts 'v' + current[0].to_s + '.' + current[1].to_s + '.' + (current[2] + 1).to_s
endruby)
NEXTTAG=`git tag | ruby -e "$RUBY"`
set -x
git tag $NEXTTAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment