filter {.git,.hg.svn}
authorMichael Wallner <mike@php.net>
Mon, 30 Mar 2015 19:45:57 +0000 (21:45 +0200)
committerMichael Wallner <mike@php.net>
Mon, 30 Mar 2015 19:45:57 +0000 (21:45 +0200)
bin/pharext
src/pharext/SourceDir/Basic.php
src/pharext/Task/PharBuild.php

index 9e1cff6f08faf1930766d458d9aa252942f7dfdd..c8de4259d0bc763a9c251de50459988ed4e2f602 100755 (executable)
Binary files a/bin/pharext and b/bin/pharext differ
index 7decdc6781f764f29ea8b3548edb6d4c2631360b..414c2015765a884f7c993316aca569f97645692c 100644 (file)
@@ -7,6 +7,7 @@ use pharext\SourceDir;
 
 use FilesystemIterator;
 use IteratorAggregate;
+use RecursiveCallbackFilterIterator;
 use RecursiveDirectoryIterator;
 use RecursiveIteratorIterator;
 
@@ -33,14 +34,22 @@ class Basic implements IteratorAggregate, SourceDir
        
        public function setArgs(Args $args) {
        }
+
+       public function filter($current, $key, $iterator) {
+               $sub = $current->getSubPath();
+               if ($sub === ".git" || $sub === ".hg" || $sub === ".svn") {
+                       return false;
+               }
+               return true;
+       }
        
        public function getIterator() {
                $rdi = new RecursiveDirectoryIterator($this->path,
                                FilesystemIterator::CURRENT_AS_SELF | // needed for 5.5
                                FilesystemIterator::KEY_AS_PATHNAME |
                                FilesystemIterator::SKIP_DOTS);
-               $rii = new RecursiveIteratorIterator($rdi,
-                       RecursiveIteratorIterator::CHILD_FIRST);
+               $rci = new RecursiveCallbackFilterIterator($rdi, [$this, "filter"]);
+               $rii = new RecursiveIteratorIterator($rci);
                foreach ($rii as $path => $child) {
                        if (!$child->isDir()) {
                                yield $path;
index 5468755832d34ed61f97b7e9710ed9931616e054..bc79f79e61e018e1b194f2d0bf7d81652b6e37a7 100644 (file)
@@ -86,10 +86,6 @@ class PharBuild implements Task
 
                $phar->stopBuffering();
                
-               foreach (new \RecursiveIteratorIterator($phar) as $file) {
-                       printf("Packaged %s ...\n", $file);
-               }
-
                if (!chmod($temp, fileperms($temp) | 0111)) {
                        throw new Exception;
                }