Skip to content

Commit

Permalink
always run pre-commit MANIFEST check, add a manifest test
Browse files Browse the repository at this point in the history
  • Loading branch information
dginev committed Nov 30, 2018
1 parent cd6006f commit d015e75
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
7 changes: 6 additions & 1 deletion MANIFEST
Expand Up @@ -694,6 +694,8 @@ t/93_formats.t
t/931_epub.t
t/94_runtimes.t
t/95_complex_config.t
t/96_fatal.t
t/97_manifest.t
t/alignment/algx.pdf
t/alignment/algx.tex
t/alignment/algx.xml
Expand Down Expand Up @@ -771,6 +773,9 @@ t/ams/matrix.xml
t/ams/sideset.pdf
t/ams/sideset.tex
t/ams/sideset.xml
t/babel/csquotes.pdf
t/babel/csquotes.tex
t/babel/csquotes.xml
t/babel/french.pdf
t/babel/french.tex
t/babel/french.xml
Expand Down Expand Up @@ -802,6 +807,7 @@ t/complex/xii.pdf
t/complex/xii.tex
t/complex/xii.xml
t/daemon/amsarticle.tex
t/daemon/broken.tex
t/daemon/api/port.spec
t/daemon/api/port.status
t/daemon/api/port.xml
Expand Down Expand Up @@ -1448,4 +1454,3 @@ t/tokenize/verb.xml
t/tokenize/verbata.pdf
t/tokenize/verbata.tex
t/tokenize/verbata.xml

8 changes: 8 additions & 0 deletions MANIFEST.SKIP
Expand Up @@ -3,6 +3,7 @@
^\.
^Makefile$
^Makefile.old$
^MYMETA
\.bak$
($|/)TAGS$
(^|/)\.svn/
Expand All @@ -11,3 +12,10 @@
^release/
^tools/
^pm_to_blib$
\.aux$
\.log$
\.tdy$
\.test.status$
\.fls$
\.synctex\.gz$
\.fdb_latexmk$
9 changes: 9 additions & 0 deletions t/97_manifest.t
@@ -0,0 +1,9 @@
use ExtUtils::Manifest qw(fullcheck);
use Test::More;

my($missing, $extra) = fullcheck();

ok(!@$missing, "MANIFEST contains outdated files: \n\t".join("\n\t", @$missing));
ok(!@$extra, "Files missing from MANIFEST: \n\t".join("\n\t", @$extra));

done_testing();
37 changes: 19 additions & 18 deletions tools/pre-commit
Expand Up @@ -38,24 +38,25 @@ if (my @modified_files =
if ($code) {
push(@failed_files, $modified_file); # Note the original file name
$exit_code = $code; } }

if (@failed_files) {
print STDERR "Some files had issues: " . join(',', @failed_files)
. "; To correct these, run:\n tools/latexmllint <files>.\n"
. colored("COMMIT ABORTED", 'red') . "\n"; }
else {
# Check if files are missing from the manifest
my %manifest = ();
open(my $fh, "<", "MANIFEST") or die "Missing MANIFEST file?\n";
while (<$fh>) {
next if /^[#]/;
chomp;
$manifest{$_} = 1; }
close($fh);
# Not in MANIFEST, (or in tools)
if (my @missing_files = grep { !($_ =~ /^tools/ || $manifest{$_}) } @modified_files) {
print STDERR "Some files are missing from MANIFEST, please add them: \n\t"
. join(',\n\t', @missing_files) . ";\n"
. colored("COMMIT ABORTED", 'red') . "\n";
exit 1; } }
. "; To correct these, run:\n tools/latexmllint <files>.\n"; }

# Also, Check if files are missing from the manifest
my %manifest = ();
open(my $fh, "<", "MANIFEST") or die "Missing MANIFEST file?\n";
while (<$fh>) {
next if /^[#]/;
chomp;
$manifest{$_} = 1; }
close($fh);
# Not in MANIFEST, (or in tools)
my @missing_files = grep { !($_ =~ /^tools|MANIFEST/ || $manifest{$_}) } @modified_files;
if (@missing_files) {
print STDERR "Some files are missing from MANIFEST, please add them: \n\t"
. join(',\n\t', @missing_files) . ";\n";
$exit_code = 1; }

if (@missing_files || @failed_files) {
print STDERR colored("COMMIT ABORTED", 'red') . "\n"; }
exit $exit_code; }

0 comments on commit d015e75

Please sign in to comment.