Loading and use of IkiWiki::Receive can all be pushed into the git plugin,
rather than scattered around.
I had at first wanted to make a receive plugin and move it there,
but a plugin was not a good fit; you don't want users to have to manually
load it, and making the git plugin load the receive plugin at the right
times would need more, and ugly code.
sub import {
hook(type => "checkconfig", id => "git", call => \&checkconfig);
hook(type => "getsetup", id => "git", call => \&getsetup);
sub import {
hook(type => "checkconfig", id => "git", call => \&checkconfig);
hook(type => "getsetup", id => "git", call => \&getsetup);
+ hook(type => "genwrapper", id => "git", call => \&genwrapper);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
if (defined $config{git_test_receive_wrapper} &&
length $config{git_test_receive_wrapper}) {
push @{$config{wrappers}}, {
if (defined $config{git_test_receive_wrapper} &&
length $config{git_test_receive_wrapper}) {
push @{$config{wrappers}}, {
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
+
+ # Run receive test only if being called by the wrapper, and not
+ # when generating same.
+ if ($config{test_receive} && ! exists $config{wrapper}) {
+ require IkiWiki::Receive;
+ IkiWiki::Receive::test();
+ }
+sub genwrapper {
+ if ($config{test_receive}) {
+ require IkiWiki::Receive;
+ return IkiWiki::Receive::genwrapper();
+ }
+ else {
+ return "";
+ }
+}
+
sub safe_git (&@) {
# Start a child process safely without resorting /bin/sh.
# Return command output or success state (in scalar context).
sub safe_git (&@) {
# Start a child process safely without resorting /bin/sh.
# Return command output or success state (in scalar context).
package IkiWiki::Receive;
use warnings;
package IkiWiki::Receive;
use warnings;
! grep { $_ eq $user } @{$config{untrusted_committers}};
}
! grep { $_ eq $user } @{$config{untrusted_committers}};
}
# Test for commits from untrusted committers in the wrapper, to
# Test for commits from untrusted committers in the wrapper, to
- # avoid loading ikiwiki at all for trusted commits.
+ # avoid starting ikiwiki proper at all for trusted commits.
"u != $uid";
} @{$config{untrusted_committers}}).
") exit(0);\n";
"u != $uid";
} @{$config{untrusted_committers}}).
") exit(0);\n";
$ret.=<<"EOF";
asprintf(&s, "CALLER_UID=%i", u);
newenviron[i++]=s;
$ret.=<<"EOF";
asprintf(&s, "CALLER_UID=%i", u);
newenviron[i++]=s;
-
- if ($config{test_receive}) {
- require IkiWiki::Receive;
- }
my @wrapper_hooks;
run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
my @wrapper_hooks;
run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
elsif ($config{post_commit} && ! commit_hook_enabled()) {
# do nothing
}
elsif ($config{post_commit} && ! commit_hook_enabled()) {
# do nothing
}
- elsif ($config{test_receive}) {
- require IkiWiki::Receive;
- IkiWiki::Receive::test();
- }
else {
if ($config{rebuild}) {
debug(gettext("rebuilding wiki.."));
else {
if ($config{rebuild}) {
debug(gettext("rebuilding wiki.."));