t/altid_v2.t
t/cgi.t
t/check-www-inbox.perl
+t/clone-coderepo-puh1.sh
+t/clone-coderepo-puh2.sh
t/clone-coderepo.psgi
t/clone-coderepo.t
t/cmd_ipc.t
ft_rename($ft, "$dn/$bn", 0666);
}
+sub run_next_puh {
+ my ($self) = @_;
+ my $puh = shift @{$self->{-puh_todo}} // return;
+ my $fini = PublicInbox::OnDestroy->new($$, \&run_next_puh, $self);
+ my $cmd = [ @$puh, ($self->{cur_dst} // $self->{dst}) ];
+ my $opt = +{ map { $_ => $self->{lei}->{$_} } (0..2) };
+ start_cmd($self, $cmd, undef, $opt, $fini);
+}
+
+sub run_post_update_hooks {
+ my ($self) = @_;
+ my $puh = $self->{-puh} // return;
+ @{$self->{-puh_todo}} = @$puh;
+ run_next_puh($self);
+}
+
# modifies the to-be-written manifest entry, and sets values from it, too
sub update_ent {
my ($self) = @_;
}
eval { set_description($self) };
warn $@ if $@;
+ run_post_update_hooks($self);
return if ($self->{-is_epoch} ||
$self->{lei}->{opt}->{'inbox-config'} ne 'always');
write_makefile($dst, 1);
$self->{dry_run} = 1 if $lei->{opt}->{'dry-run'};
umask($lei->{client_umask}) if defined $lei->{client_umask};
$self->{-initial_clone} = 1 if !-d $self->{dst};
+ if (defined(my $puh = $lei->{opt}->{'post-update-hook'})) {
+ require Text::ParseWords;
+ for (@$puh) {
+ my $pfx = [ Text::ParseWords::shellwords($_) ];
+ push @{$self->{-puh}}, $pfx;
+ }
+ }
eval {
my $ic = $lei->{opt}->{'inbox-config'} //= 'always';
$ic =~ /\A(?:v1|v2|always|never)\z/s or die <<"";
# support both :/
GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@
inbox-config=s inbox-version=i objstore=s manifest=s
- project-list|projectslist=s
+ project-list|projectslist=s post-update-hook=s@
prune|p keep-going|k
dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help;
if ($opt->{help}) { print $help; exit };
--- /dev/null
+#!/bin/sh
+# sample --post-update-hook for t/clone-coderepo.t test
+case $CLONE_CODEREPO_TEST_OUT in
+'') ;;
+*) echo "uno $@" >> "$CLONE_CODEREPO_TEST_OUT" ;;
+esac
--- /dev/null
+#!/bin/sh
+# sample --post-update-hook for t/clone-coderepo.t test
+case $CLONE_CODEREPO_TEST_OUT in
+'') ;;
+*) echo "dos $@" >> "$CLONE_CODEREPO_TEST_OUT" ;;
+esac
use PublicInbox::TestCommon;
use PublicInbox::Import;
use File::Temp;
+use File::Path qw(remove_tree);
use Digest::SHA qw(sha1_hex);
require_mods(qw(json Plack::Builder HTTP::Date HTTP::Status));
require_git '1.8.5';
like($err, qr/no longer exist.*\bgone\.git\b/s, 'gone.git noted');
}
+{
+ my $x = [qw(-clone --inbox-config=never --manifest= --project-list=
+ --objstore= -p), $url, "$tmpdir/dst",
+ '--post-update-hook=./t/clone-coderepo-puh1.sh',
+ '--post-update-hook=./t/clone-coderepo-puh2.sh' ];
+ my $log = "$tmpdir/puh.log";
+ my $env = { CLONE_CODEREPO_TEST_OUT => $log };
+ ok(run_script($x, $env), 'no-op clone w/ post-update-hook');
+ ok(!-e $log, 'hooks not run on no-op');
+ remove_tree("$tmpdir/dst");
+ ok(run_script($x, $env), 'fresh clone w/ post-update-hook');
+ ok(-e $log, 'hooks run on fresh clone');
+ open my $lh, '<', $log or xbail "open $log: $!";
+ chomp(my @l = readline($lh));
+ is(scalar(@l), 4, '4 lines written by hooks');
+ for my $r (qw(a b)) {
+ is_xdeeply(['uno', 'dos'],
+ [ (map { s/ .+//; $_ } grep(m!/$r\.git\z!, @l)) ],
+ "$r.git hooks ran in order") or diag explain(\@l);
+ }
+}
done_testing;