Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test, doc, implement #!include_default as memory-only, not changing disk file #17

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.73 2021-01-16
- Calculate absolute path to MANIFEST.SKIP (in $DEFAULT_MSKIP) at module
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