Subject: | Allow GatherDir to collect files from symlinked directories. |
The attached patch allows this for example:
[GatherDir]
root = foo
follow_symlinks = 1
Subject: | 0001-Allow-GatherDir-to-collect-from-symlinked-directorie.patch |
From 9c9fd1eec0cacf05551042c40ff15e5086215467 Mon Sep 17 00:00:00 2001
From: Luc St-Louis <lucs@pobox.com>
Date: Thu, 3 Feb 2011 11:16:29 -0500
Subject: [PATCH] Allow GatherDir to collect from symlinked directories.
---
lib/Dist/Zilla/Plugin/GatherDir.pm | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/lib/Dist/Zilla/Plugin/GatherDir.pm b/lib/Dist/Zilla/Plugin/GatherDir.pm
index 3d60da4..1f47731 100644
--- a/lib/Dist/Zilla/Plugin/GatherDir.pm
+++ b/lib/Dist/Zilla/Plugin/GatherDir.pm
@@ -84,6 +84,20 @@ has include_dotfiles => (
default => 0,
);
+=attr follow_symlinks
+
+By default, directories that are symlinks will not be followed. Note on the
+other hand that in all followed directories, files which are symlinks are
+always gathered.
+
+=cut
+
+has follow_symlinks => (
+ is => 'ro',
+ isa => 'Bool',
+ default => 0,
+);
+
sub gather_files {
my ($self) = @_;
@@ -92,7 +106,9 @@ sub gather_files {
$root = Path::Class::dir($root);
my @files;
- FILE: for my $filename (File::Find::Rule->file->in($root)) {
+ my $rule = File::Find::Rule->new();
+ $rule->extras({follow => $self->follow_symlinks});
+ FILE: for my $filename ($rule->file->in($root)) {
unless ($self->include_dotfiles) {
my $file = file($filename)->relative($root);
next FILE if $file->basename =~ qr/^\./;
--
1.7.3