include temp file for attachment change too
authorJoey Hess <joey@kodama.kitenet.net>
Fri, 24 Oct 2008 17:44:03 +0000 (13:44 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Fri, 24 Oct 2008 17:44:03 +0000 (13:44 -0400)
IkiWiki/Plugin/git.pm
IkiWiki/Receive.pm
doc/plugins/write.mdwn

index 3a8476e7d24444531f733b6b2b2ae64ce7d8105b..84df561817e7123f6f3f5f3062e4d2ab13445419 100644 (file)
@@ -619,7 +619,7 @@ sub rcs_receive () { #{{{
                
                # Avoid chdir when running git here, because the changes
                # are in the master git repo, not the srcdir repo.
-               # The pre-receive hook already puts us in the right place.
+               # The pre-recieve hook already puts us in the right place.
                $no_chdir=1;
                my @changes=git_commit_info($oldrev."..".$newrev);
                $no_chdir=0;
@@ -643,15 +643,6 @@ sub rcs_receive () { #{{{
                                elsif ($detail->{'status'} =~ /^[AM]+\d*$/) {
                                        $action="add";
                                        $mode=$detail->{'mode_to'};
-                                       if (! pagetype($file)) {
-                                               eval q{use File::Temp};
-                                               die $@ if $@;
-                                               my $fh;
-                                               ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1);
-                                               if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) {
-                                                       error("failed writing temp file");
-                                               }
-                                       }
                                }
                                elsif ($detail->{'status'} =~ /^[DAM]+\d*/) {
                                        $action="remove";
@@ -670,6 +661,18 @@ sub rcs_receive () { #{{{
                                                error gettext("you are not allowed to change file modes");
                                        }
                                }
+                               
+                               # extract attachment to temp file
+                               if (($action eq 'add' || $action eq 'change') &&
+                                    ! pagetype($file)) {
+                                       eval q{use File::Temp};
+                                       die $@ if $@;
+                                       my $fh;
+                                       ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1);
+                                       if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) {
+                                               error("failed writing temp file");
+                                       }
+                               }
 
                                push @rets, {
                                        file => $file,
index c69911a7cfbe0130ef7acf8e5b035e7aeaa880ee..9a672abc99ca2742f5373d737280ad8a6bbe830a 100644 (file)
@@ -45,7 +45,7 @@ sub test () { #{{{
                $file=IkiWiki::possibly_foolish_untaint($file);
                if (! defined $file || ! length $file ||
                    IkiWiki::file_pruned($file, $config{srcdir})) {
-                       error(gettext("bad file name"));
+                       error(gettext("bad file name %s"), $file);
                }
 
                my $type=pagetype($file);
index 5ee4acb539ed15b1184a827dfb39aeb9f4c7c7cf..abcabbdc39e43871af4b491b47b1540fda99a34f 100644 (file)
@@ -837,8 +837,8 @@ files that were changed, in the form:
                file => # name of file that was changed
                action => # either "add", "change", or "remove"
                path => # temp file containing the new file content, only
-                       # needed for "add", and only if the file is an
-                       # attachment, not a page
+                       # needed for "add"/"change", and only if the file
+                       # is an attachment, not a page
        }
 
 The list will then be checked to make sure that each change is one that