a5f8ad2a835b43f44e1942bb5a2cfe2fcc2598e1
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 29_handle_version.pl
1
2 my $dbic_ver_re = qr/ (\d) \. (\d{2}) (\d{3}) (?: _ (\d{2}) )? /x; # not anchored!!!
3
4 my $version_string = Meta->version;
5 my $version_value = eval $version_string;
6
7 my ($v_maj, $v_min, $v_point, $v_dev) = $version_string =~ /^$dbic_ver_re$/
8   or die sprintf (
9     "Invalid version %s (as specified in %s)\nCurrently valid version formats are M.VVPPP or M.VVPPP_DD\n",
10     $version_string,
11     Meta->{values}{version_from} || Meta->{values}{all_from} || 'Makefile.PL',
12   )
13 ;
14
15 if ($v_maj != 0 or $v_min > 8) {
16   die "Illegal version $version_string - we are still in the 0.08 cycle\n"
17 }
18
19
20 # all odd releases *after* 0.08200 generate a -TRIAL, no exceptions
21 Meta->makemaker_args->{DISTVNAME} = Meta->name . "-$version_string-TRIAL"
22   if ( $v_point > 200 and int($v_point / 100) % 2 );
23
24
25 my $tags = { map { chomp $_; $_ => 1} `git tag` };
26 # git may not be available
27 if (keys %$tags) {
28   my $shipped_versions;
29   my $shipped_dev_versions;
30
31   for (keys %$tags) {
32     if ($_ =~ /^v$dbic_ver_re$/) {
33       if (defined $4) {
34         $shipped_dev_versions->{"$1.$2$3$4"} = 1;
35       }
36       else {
37         $shipped_versions->{"$1.$2$3"} = 1;
38       }
39       delete $tags->{$_};
40     }
41   }
42
43   die sprintf "Tags in unknown format found: %s\n", join ', ', keys %$tags
44     if keys %$tags;
45 }
46
47 # keep the Makefile.PL eval happy
48 1;