@leroysheep / BookAlchemy / commits / 33ac7d2250

Meta/CheckPush: minor versions could have more than one digit

Add compare_dotted_version helper and use it Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jun 19, 2012 at 15:19 UTC 33ac7d225051008f5fc2d13cbd0c3d36a5b6122b
1 file changed +27 -1
CheckPush
+27 -1
index 7ce0d9a411..fcdc059b78 100755 --- a/CheckPush +++ b/CheckPush @@ -4,7 +4,33 @@ for range in $( prev_branch= { git for-each-ref --format='%(refname)' refs/heads/maint-* | - sed -e 's|^refs/heads/||' + perl -e ' + sub compare_dotted_version { + my (@ours) = split(/\./, $_[0]); + my (@theirs) = split(/\./, $_[1]); + my ($i, $diff); + + for ($i = 0; $i < @ours && $i < @theirs; $i++) { + $diff = $ours[$i] - $theirs[$i]; + return $diff if ($diff); + } + return 1 if ($i < @ours); + return -1 if ($i < @theirs); + return 0; + } + my @maint = (); + while (<STDIN>) { + next unless s|^refs/heads/||; + chomp; + my ($v) = ($_ =~ /^maint-(.*)$/); + push @maint, [$v, $_]; + } + for (map { $_->[1] } + sort { compare_dotted_version($a->[0], $b->[0]) } + @maint) { + print "$_\n"; + } + ' cat <<-EOF maint master