Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (27 sloc) 0.805 kB
package Rakudo::CompareRevisions;
use strict;
use warnings;
use base qw(Exporter);
our @EXPORT_OK = qw(compare_parrot_revs parse_parrot_git_describe);
sub parse_parrot_git_describe {
my $g = shift;
my $sep = qr/[_\W]/;
$g =~ /^REL(?:EASE)?$sep(\d+)$sep(\d+)$sep(\d+)(?:-(\d+)-g[a-f0-9]*)?$/
or die "Invalid revision specifier: '$g' "
."(expected something of format RELEASE_1_2_3-123-gdeadbee)\n";
my @c = ($1, $2, $3, $4 || 0);
return @c;
}
sub compare_parrot_revs {
my ($aa, $bb) = @_;
return 1 if $bb =~ /^r?\d+$/;
return -1 if $aa =~ /^r?\d+$/;
my @a = parse_parrot_git_describe($aa);
my @b = parse_parrot_git_describe($bb);
for (0..3) {
my $cmp = $a[$_] <=> $b[$_];
return $cmp if $cmp;
}
return 0;
}
1;
Jump to Line
Something went wrong with that request. Please try again.