Cherry picks from current/for_cpan_index (flux due to not-yet-clear-policy)
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 29_handle_version.pl
CommitLineData
acdfdae0 1
e56f8014 2my $dbic_ver_re = qr/ 0 \. (\d{2}) (\d{2}) (\d{2}) (?: _ (\d{2}) )? /x; # not anchored!!!
acdfdae0 3
4my $version_string = Meta->version;
5my $version_value = eval $version_string;
6
7my ($v_maj, $v_min, $v_point, $v_dev) = $version_string =~ /^$dbic_ver_re$/
8 or die sprintf (
e56f8014 9 "Invalid version %s (as specified in %s)\nCurrently valid version formats are 0.MMVVPP or 0.MMVVPP_DD\n",
acdfdae0 10 $version_string,
11 Meta->{values}{version_from} || Meta->{values}{all_from} || 'Makefile.PL',
12 )
13;
14
e56f8014 15if ($v_maj > 8) {
acdfdae0 16 die "Illegal version $version_string - we are still in the 0.08 cycle\n"
17}
18
1d29e7e2 19#Meta->makemaker_args->{DISTVNAME} = Meta->name . "-$version_string-TRIAL" if (
20# ( $v_point > 89 )
21#);
acdfdae0 22
23
24my $tags = { map { chomp $_; $_ => 1} `git tag` };
25# git may not be available
26if (keys %$tags) {
27 my $shipped_versions;
28 my $shipped_dev_versions;
29
e56f8014 30 my $legacy_re = qr/^ v 0 \. (\d{2}) (\d{2}) (\d) (?: _ (\d{2}) )? $/x;
31
acdfdae0 32 for (keys %$tags) {
e56f8014 33 if ($_ =~ /^v$dbic_ver_re$/ or $_ =~ $legacy_re ) {
acdfdae0 34 if (defined $4) {
e56f8014 35 $shipped_dev_versions->{"0.$1$2$3$4"} = 1;
acdfdae0 36 }
37 else {
e56f8014 38 $shipped_versions->{"0.$1$2$3"} = 1;
acdfdae0 39 }
40 delete $tags->{$_};
41 }
42 }
43
44 die sprintf "Tags in unknown format found: %s\n", join ', ', keys %$tags
45 if keys %$tags;
46}
47
48# keep the Makefile.PL eval happy
491;