This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
version has been upgraded from version 0.9903 to 0.9904
[perl5.git] / Porting / cmpVERSION.pl
index ebf57cf..46f1fef 100755 (executable)
@@ -39,10 +39,17 @@ my $null = devnull();
 unless (defined $tag_to_compare) {
     # Thanks to David Golden for this suggestion.
 
-    $tag_to_compare = `git describe --abbrev=0`;
+    $tag_to_compare = `git describe --abbrev=0 2>$null`;
     chomp $tag_to_compare;
 }
 
+unless (length $tag_to_compare) {
+    die "$0: Git found, but no Git tags found\n"
+       unless $tap;
+    print "1..0 # SKIP: Git found, but no Git tags found\n";
+    exit 0;
+}
+
 my $tag_exists = `git --no-pager tag -l $tag_to_compare 2>$null`;
 chomp $tag_exists;
 
@@ -70,8 +77,9 @@ my %skip;
 @skip{
     'lib/Carp/Heavy.pm',
     'lib/Config.pm',           # no version number but contents will vary
-    'lib/Exporter/Heavy.pm',
+    'dist/Exporter/lib/Exporter/Heavy.pm',
     'win32/FindExt.pm',
+    'dist/Attribute-Handlers/demo/MyClass.pm', # it's just demonstration code
 } = ();
 
 # Files to skip just for particular version(s),
@@ -146,6 +154,7 @@ printf "1..%d\n" => scalar keys %module_diffs if $tap;
 
 my $count;
 my $diff_cmd = "git --no-pager diff $tag_to_compare ";
+my $q = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') ? '"' : "'";
 my (@diff);
 
 foreach my $pm_file (sort keys %module_diffs) {
@@ -157,7 +166,8 @@ foreach my $pm_file (sort keys %module_diffs) {
     ++$count;
 
     if (!defined $orig_pm_version || $orig_pm_version eq 'undef') { # sigh
-        print "ok $count - SKIP Can't pass \$VERSION in $pm_file\n" if $tap;
+        print "ok $count - SKIP Can't parse \$VERSION in $pm_file\n"
+          if $tap;
     } elsif (!defined $pm_version || $pm_version eq 'undef') {
         print "not ok $count - in $pm_file version was $orig_pm_version, now unparsable\n" if $tap;
     } elsif ($pm_version ne $orig_pm_version) { # good
@@ -165,7 +175,7 @@ foreach my $pm_file (sort keys %module_diffs) {
     } else {
        if ($tap) {
            foreach (sort @{$module_diffs{$pm_file}}) {
-               print "# $_" for `$diff_cmd '$_'`;
+               print "# $_" for `$diff_cmd $q$_$q`;
            }
            if (exists $skip_versions{$pm_file}
                and grep $pm_version eq $_, @{$skip_versions{$pm_file}}) {
@@ -183,12 +193,14 @@ foreach my $pm_file (sort keys %module_diffs) {
 sub get_file_from_git {
     my ($file, $tag) = @_;
     local $/;
+
+    use open IN => ':raw';
     return scalar `git --no-pager show $tag:$file 2>$null`;
 }
 
 if ($diffs) {
     for (sort @diff) {
        print "\n";
-       system "$diff_cmd '$_'";
+       system "$diff_cmd $q$_$q";
     }
 }