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

ttree 2.22 --copy option behaviour change, with --accept [rt.cpan.org #49567] #148

Open
atoomic opened this issue Oct 5, 2018 · 1 comment

Comments

@atoomic
Copy link
Collaborator

atoomic commented Oct 5, 2018

Migrated from rt.cpan.org#49567 (status was 'open')

Requestors:

Attachments:

From dgp@corefiling.com on 2009-09-09 16:24:48:

ttree 2.22 has a logic change in process_tree causing files to be 
skipped if they are not in the --accept list, even if they are in --copy.

In 2.19 I could use "ttree -s src -d out -r --accept=\.html$ 
--copy='\.(jpg|gif|css)$'" and it works as documented:
#############
ttree 2.9 (Template Toolkit version 2.19)

      Source: src
 Destination: out
Include Path: [  ]
      Ignore: [  ]
        Copy: [ \.(jpg|gif|css)$ ]
      Accept: [ .html$ ]
      Suffix: [  ]

  + index.html                     
  > logo.jpg                         (copied, matches /\.(jpg|gif|css)$/)
  > img.gif                          (copied, matches /\.(jpg|gif|css)$/)
#############

But 2.22 skips files in copy:
#############
ttree 2.9 (Template Toolkit version 2.22)

      Source: src
 Destination: out
Include Path: [  ]
      Ignore: [  ]
        Copy: [ \.(jpg|gif|css)$ ]
      Accept: [ .html$ ]
      Suffix: [  ]

  + index.html                     
  - logo.jpg                         (not accepted)
  - img.gif                          (not accepted)

     Summary:
            1 file processed
            0 files copied
            0 directories created
            0 files skipped (not modified)
            2 files skipped (ignored)
#############

Also attaching a simple patch that returns to the 1.19 (and documented) 
behaviour.

-- 
Daniel Piddock, System Administrator, CoreFiling Limited
http://www.corefiling.com

From mkanat@cpan.org on 2010-07-22 08:34:23:

On Wed Sep 09 12:24:48 2009, dgp@corefiling.com wrote:
> ttree 2.22 has a logic change in process_tree causing files to be 
> skipped if they are not in the --accept list, even if they are in --
copy.

  Hey hey. Any hope of getting a fix for this bug into a release of TT? 
This has been breaking our website build for a *really* long time now 
every time we accidentally upgrade our TT.

From bgrimm@cpan.org on 2010-09-10 12:06:40:

An easy workaround is to just add "." to the accept list.  Recursion 
works properly along with filters like "copy \.html$" 

On Thu Jul 22 04:34:23 2010, MKANAT wrote:
> On Wed Sep 09 12:24:48 2009, dgp@corefiling.com wrote:
> > ttree 2.22 has a logic change in process_tree causing files to be 
> > skipped if they are not in the --accept list, even if they are in --
> copy.
> 
>   Hey hey. Any hope of getting a fix for this bug into a release of TT? 
> This has been breaking our website build for a *really* long time now 
> every time we accidentally upgrade our TT.

@toddr
Copy link
Collaborator

toddr commented Oct 5, 2018

diff -ruN 2.22/ttree mine/ttree
--- 2.22/ttree	2009-09-09 17:20:20.539677587 +0100
+++ mine/ttree	2009-09-09 17:17:57.451717844 +0100
@@ -296,16 +296,6 @@
             }
         }
 
-        # check against acceptance list
-        if (@$accept) {
-            unless ((-d $abspath && $recurse) || grep { $path =~ /$_/ } @$accept) {
-                printf yellow("  - %-32s (not accepted)\n"), $path
-                    if $verbose > 1;
-                $n_skip++;
-                next FILE;
-            }
-        }
-
         if (-d $abspath) {
             if ($recurse) {
                 my ($uid, $gid, $mode);
@@ -383,6 +373,16 @@
         }
     }
 
+    # check against acceptance list
+    if (not $copy_file and @$accept) {
+        unless (grep { $filename =~ /$_/ } @$accept) {
+            printf yellow("  - %-32s (not accepted)\n"), $file
+                if $verbose > 1;
+            $n_skip++;
+            return;
+        }
+    }
+
     # stat the source file unconditionally, so we can preserve
     # mode and ownership
     ( undef, undef, $mode, undef, $uid, $gid, undef, 

toddr added a commit that referenced this issue Oct 8, 2018
Resolves GH #148: Previously process_tree would not skip files if they
were missing from the --accept list. But were in the --copy.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 24, 2018
Upstream changes:
Version 2.28 - 11th October 2018
#------------------------------------------------------------------------

* Add and enable Travis CI to track GitHub Pull Requests

* Template is now using GitHub as the official Bug Tracker

* Nicolas R. fixed a circular reference in Template::Plugin::Filter
  abw/Template2#152

* Nicolas R. adjusted group regexes to not be greedy
  abw/Template2#94

* Nicolas R. added unit tests to cover regression from RT 91172
  abw/Template2#122

* Nicolas R. added support for template files having mtime=0
  abw/Template2#102

* Todd Rinaldo fixed rand calls with no args in Math plugin
  abw/Template2#155

* Todd Rinaldo corrected ttree 2.22 logic change
  abw/Template2#148

* Todd Rinaldo turned off automated testing for tests using optional modules
  abw/Template2#156

* Nicolas R. adjusted unit tests to not force Stash::XS

* Nicolas R. added a pre allocated buffer in Stash.xs to avoid malloc/free
  abw/Template2#82

* Nicolas R. optmized Template::Parser by avoiding a dummy sub
  abw/Template2#83

* Nicolas R. optimized Template:Directive by using index
  abw/Template2#84

* Nicolas R. adjust _dotop logic in Stash for perl 5.28 and earlier
  abw/Template2#81

* Todd Rinaldo documented VMethod method called 'item'
  abw/Template2#90

* Nicolas R. adjusted t/filter.t after recent switch to RFC3986
  abw/Template2#179

* Nicolas R. fixed warnings from t/cgi.t
  abw/Template2#178

* Ivan Krylov added STRICT option to ttree
  abw/Template2#81

* Kent Fredric fixed relative path handling in templates on Perl 5.26+
  abw/Template2#80

* Tom Delmas fixed some typo from documentation
  abw/Template2#76

* Matthew Somerville switched uri/url to use RFC3986
  updated the documentation to match the history.
  abw/Template2#35

* Sebastien Deseille used remove_tree helper to remove directories
  abw/Template2#67

* Nick Hibma - Add Sortkeys to DUMPER_ARGS
  abw/Template2#64

* E. Choroba added a warn on duplicate block name
  abw/Template2#61

* Jason Lewis fixed some typo in ttree.pod
  abw/Template2#58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants