Skip to content

Commit

Permalink
Merge pull request #17 from mohawk2/includedefault-memonly
Browse files Browse the repository at this point in the history
Test, doc, implement #!include_default as memory-only, not changing disk file
  • Loading branch information
karenetheridge authored Apr 28, 2023
2 parents 5c36aa0 + 308b16c commit b0713e7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Revision history for ExtUtils-Manifest

{{$NEXT}}
- #!include_default now memory-only, not changing MANIFEST.SKIP file.

1.74 2023-04-28
- Add some MANIFEST.SKIP patterns for bzr/brz
Expand Down
48 changes: 29 additions & 19 deletions lib/ExtUtils/Manifest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ a given filename should be skipped.
=cut
sub _process_skipline {
local $_ = shift;
chomp;
s/\r//;
$_ =~ qr{^\s*(?:(?:'([^\\']*(?:\\.[^\\']*)*)')|([^#\s]\S*))?(?:(?:\s*)|(?:\s+(.*?)\s*))$};
#my $comment = $3;
my $filename = $2;
if ( defined($1) ) {
$filename = $1;
$filename =~ s/\\(['\\])/$1/g;
}
$filename;
}

# returns an anonymous sub that decides if an argument matches
sub maniskip {
my @skip ;
Expand All @@ -412,16 +426,14 @@ sub maniskip {
local(*M, $_);
open M, "< $mfile" or open M, "< $DEFAULT_MSKIP" or return sub {0};
while (<M>){
chomp;
s/\r//;
$_ =~ qr{^\s*(?:(?:'([^\\']*(?:\\.[^\\']*)*)')|([^#\s]\S*))?(?:(?:\s*)|(?:\s+(.*?)\s*))$};
#my $comment = $3;
my $filename = $2;
if ( defined($1) ) {
$filename = $1;
$filename =~ s/\\(['\\])/$1/g;
if (/^#!include_default\s*$/) {
if (my @default = _include_mskip_file()) {
warn "Debug: Including default MANIFEST.SKIP\n" if $Debug;
push @skip, grep $_, map _process_skipline($_), @default;
}
next;
}
next if (not defined($filename) or not $filename);
next unless my $filename = _process_skipline($_);
push @skip, _macify($filename);
}
close M;
Expand Down Expand Up @@ -452,14 +464,6 @@ sub _check_mskip_directives {
return;
}
while (<M>) {
if (/^#!include_default\s*$/) {
if (my @default = _include_mskip_file()) {
push @lines, @default;
warn "Debug: Including default MANIFEST.SKIP\n" if $Debug;
$flag++;
}
next;
}
if (/^#!include\s+(.*)\s*$/) {
my $external_file = $1;
if (my @external = _include_mskip_file($external_file)) {
Expand Down Expand Up @@ -809,11 +813,17 @@ files. At present two such directives are recognized.
=item #!include_default
This inserts the contents of the default MANIFEST.SKIP file
This tells ExtUtils::Manifest to read the default F<MANIFEST.SKIP>
file and skip files accordingly, but I<not> to include it in the local
F<MANIFEST.SKIP>. This is intended to skip files according to a system
default, which can change over time without requiring further changes
to the distribution's F<MANIFEST.SKIP>.
=item #!include /Path/to/another/manifest.skip
This inserts the contents of the specified external file
This inserts the contents of the specified external file in the local
F<MANIFEST.SKIP>. This is intended for authors to have a central
F<MANIFEST.SKIP> file, and to include it with their various distributions.
=back
Expand Down
9 changes: 8 additions & 1 deletion t/Manifest.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BEGIN {
}
chdir 't';

use Test::More tests => 98;
use Test::More tests => 99;
use Cwd;

use File::Spec;
Expand Down Expand Up @@ -438,6 +438,13 @@ my @funky_keys = qw(space space_quote space_backslash space_quote_backslash);

my $extsep = $Is_VMS_noefs ? '_' : '.';
$Files{"$_.bak"}++ for ('MANIFEST', "MANIFEST${extsep}SKIP");

my $mskip_contents = do {
local $/;
open my $fh, '<', "MANIFEST${extsep}SKIP" or return;
<$fh>;
};
unlike $mskip_contents, qr{^\Q^my\E}m, 'include_default memory-only';
}

add_file('MANIFEST' => 'Makefile.PL');
Expand Down

0 comments on commit b0713e7

Please sign in to comment.