Created
May 11, 2011 19:01
-
-
Save osheroff/967075 to your computer and use it in GitHub Desktop.
git-prodtag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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