Commit | Line | Data |
---|---|---|
4d1e77f9 | 1 | #!/usr/bin/perl |
93209f39 | 2 | |
a7d002a1 DM |
3 | # output a list of: |
4 | # a) files listed in MANIFEST which don't exist | |
5 | # b) files which exist but which aren't in MANIFEST | |
6 | ||
f73a32e0 | 7 | use v5.14; |
4d1e77f9 | 8 | use warnings; |
93209f39 | 9 | use File::Find; |
a36da35b NC |
10 | use Getopt::Long; |
11 | use constant SKIP => 125; | |
12 | ||
13 | my $exitstatus; | |
14 | GetOptions('exitstatus!', \$exitstatus) | |
15 | or die "$0 [--exitstatus]"; | |
16 | ||
17 | my %files; | |
18 | my $missing = 0; | |
19 | my $bonus = 0; | |
93209f39 | 20 | |
1ae6ead9 | 21 | open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n"; |
a36da35b NC |
22 | for my $line (<$fh>) { |
23 | my ($file) = $line =~ /^(\S+)/; | |
24 | ++$files{$file}; | |
25 | next if -f $file; | |
26 | ++$missing; | |
27 | print "$file from MANIFEST doesn't exist\n"; | |
93209f39 | 28 | } |
a36da35b NC |
29 | close $fh; |
30 | ||
4d1e77f9 RGS |
31 | find { |
32 | wanted => sub { | |
4d1e77f9 | 33 | return if -d; |
12100751 | 34 | return if $_ eq '.mailmap'; |
3618011f | 35 | return if $_ eq '.gitignore'; |
d42c7c41 GK |
36 | return if $_ eq '.gitattributes'; |
37 | return if $_ eq '.git_patch'; | |
f73a32e0 NC |
38 | |
39 | my $x = $File::Find::name =~ s!^\./!!r; | |
3618011f | 40 | return if $x =~ /^\.git\b/; |
79ff1055 | 41 | return if $x =~ m{^\.github/}; |
a36da35b NC |
42 | return if $files{$x}; |
43 | ++$bonus; | |
44 | print "$x\t\tnot in MANIFEST\n"; | |
4d1e77f9 RGS |
45 | }, |
46 | }, "."; | |
93209f39 | 47 | |
a36da35b NC |
48 | my $exitcode = $exitstatus ? $missing + $bonus : 0; |
49 | ||
50 | # We can't (meaningfully) exit with codes above 255, so we're going to have to | |
51 | # clamp them to some range whatever we do. So as we need the code anyway, use | |
52 | # 124 as our maximum instead, and then we can run as a useful git bisect run | |
53 | # script if needed... | |
54 | ||
55 | $exitcode = SKIP - 1 | |
56 | if $exitcode > SKIP; | |
57 | ||
58 | exit $exitcode; |