check generated pages in
authorJoey Hess <joey@kodama.kitenet.net>
Tue, 29 Jul 2008 19:51:25 +0000 (15:51 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Tue, 29 Jul 2008 19:51:25 +0000 (15:51 -0400)
I considered not checking them in, or making the checkin configurable.
However, then they would remain not checked in if edited by a user, which is
probably not desired.

Note that passing undef as the username/ip to rcs_commit_staged may not
result in ideal behavior; the commit may seem to come from "anonymous" with
some revision control systems. Most of them handle it a bit better and just
have it come from whatever user is running the build.

IkiWiki/Plugin/autoindex.pm

index 0a8d90701e6f9eb2978bcedc46ea37e90eb60eed..8179ee1e72a28ba5dac9dc6911cf35b2477ac7bf 100644 (file)
@@ -16,6 +16,9 @@ sub genindex ($) { #{{{
        my $template=template("autoindex.tmpl");
        $template->param(page => $page);
        writefile($file, $config{srcdir}, $template->output);
+       if ($config{rcs}) {
+               IkiWiki::rcs_add($file);
+       }
 } #}}}
 
 sub refresh () { #{{{
@@ -45,9 +48,23 @@ sub refresh () { #{{{
                }
        }, $config{srcdir});
 
+       my @needed;
        foreach my $dir (keys %dirs) {
                if (! exists $pages{$dir}) {
-                       genindex($dir);
+                       push @needed, $dir;
+               }
+       }
+       
+       if (@needed) {
+               if ($config{rcs}) {
+                       IkiWiki::disable_commit_hook();
+               }
+               genindex($_) foreach @needed;
+               if ($config{rcs}) {
+                       IkiWiki::rcs_commit_staged(
+                               gettext("automatic index generation"),
+                               undef, undef);
+                       IkiWiki::enable_commit_hook();
                }
        }
 } #}}}