Commit | Line | Data |
---|---|---|
9dd824c0 TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Test::More; | |
4 | use ExtUtils::MakeMaker; | |
e7122a46 | 5 | use ExtUtils::Manifest 'maniread'; |
9dd824c0 | 6 | use File::Spec::Functions qw(devnull); |
d28c2742 | 7 | use Getopt::Long; |
9dd824c0 | 8 | |
d28c2742 TC |
9 | my $report; |
10 | GetOptions("r" => \$report); | |
9dd824c0 | 11 | |
d28c2742 TC |
12 | my $last_tag = shift; |
13 | ||
14 | unless ($last_tag) { | |
15 | $last_tag = `git describe --abbrev=0`; | |
16 | chomp $last_tag; | |
17 | } | |
18 | ||
19 | -d ".git" | |
9dd824c0 TC |
20 | or plan skip_all => "Only usable in a git checkout"; |
21 | ||
e7122a46 | 22 | my $mani = maniread(); |
9dd824c0 | 23 | |
e7122a46 TC |
24 | my @subdirs = qw(PNG TIFF GIF JPEG W32 T1 FT2 ICO SGI Mandelbrot CountColor DynTest); |
25 | ||
26 | my $subdir_re = "^(?:" . join("|", @subdirs) . ")/"; | |
27 | ||
28 | my @pm_files = sort | |
29 | grep /\.pm$/ && !/$subdir_re/ && !/^t\// && $_ ne 'Imager.pm', keys %$mani; | |
30 | ||
d28c2742 TC |
31 | plan tests => scalar(@subdirs) + scalar(@pm_files) |
32 | unless $report; | |
9dd824c0 TC |
33 | |
34 | for my $dir (@subdirs) { | |
b64f8bf3 TC |
35 | my @changes = `git log --abbrev --oneline $last_tag..HEAD -- $dir`; |
36 | my @more_changes = `git status --porcelain -- $dir`; | |
d28c2742 TC |
37 | if ($report) { |
38 | print "$dir updated\n" if @changes || @more_changes; | |
39 | } | |
40 | else { | |
41 | SKIP: | |
42 | { | |
43 | @changes || @more_changes | |
44 | or skip "No changes for $dir", 1; | |
45 | my $vfile = "$dir/$dir.pm"; | |
46 | my $current = eval { MM->parse_version($vfile) }; | |
47 | my $last_rel_content = get_file_from_git($vfile, $last_tag); | |
48 | my $last = eval { MM->parse_version(\$last_rel_content) }; | |
49 | unless (isnt($current, $last, "$dir updated, $vfile version bump")) { | |
50 | diag(@changes, @more_changes); | |
51 | } | |
7d046a01 | 52 | } |
9dd824c0 TC |
53 | } |
54 | } | |
55 | ||
d28c2742 TC |
56 | unless ($report) { |
57 | for my $file (@pm_files) { | |
58 | my @changes = `git log --abbrev --oneline $last_tag..HEAD $file`; | |
59 | my @more_changes = `git status --porcelain $file`; | |
60 | SKIP: | |
61 | { | |
62 | @changes || @more_changes | |
63 | or skip "No changes for $file", 1; | |
64 | my $current = eval { MM->parse_version($file) }; | |
65 | my $last_rel_content = get_file_from_git($file, $last_tag); | |
66 | my $last = eval { MM->parse_version(\$last_rel_content) }; | |
67 | unless (isnt($current, $last, "$file updated, version bump")) { | |
68 | diag(@changes, @more_changes); | |
69 | } | |
e7122a46 TC |
70 | } |
71 | } | |
72 | } | |
73 | ||
9dd824c0 TC |
74 | sub get_file_from_git { |
75 | my ($file, $tag) = @_; | |
76 | my $null = devnull(); | |
77 | local $/; | |
78 | return scalar `git --no-pager show $tag:$file 2>$null`; | |
79 | } |