our $LIVE; # pid => callback
our $FGRP_TODO; # objstore -> [ fgrp mirror objects ]
our $TODO; # reference => [ non-fgrp mirror objects ]
+our @PUH; # post-update hooks
sub keep_going ($) {
$LIVE && (!$_[0]->{lei}->{child_error} ||
my $cmd = [ 'git', "--git-dir=$fgrp->{cur_dst}",
qw(update-ref --stdin -z) ];
my $lei = $fgrp->{lei};
- my $pack = PublicInbox::OnDestroy->new($$, \&pack_dst, $fgrp);
+ my $pack = PublicInbox::OnDestroy->new($$, \&satellite_done, $fgrp);
start_cmd($fgrp, $cmd, { 0 => $r, 2 => $lei->{2} }, $pack);
close $r or die "close(r): $!";
return if $fgrp->{dry_run};
close($w) or warn "E: close(update-ref --stdin): $! (need git 1.8.5+)\n";
}
-sub pack_dst { # packs lightweight satellite repos
+sub satellite_done {
my ($fgrp) = @_;
pack_refs($fgrp, $fgrp->{cur_dst});
+ run_puh($fgrp);
}
sub pack_refs {
$self->{-show_ref} = $opt->{1};
do_reap($self);
$self->{lei}->qerr("# @$cmd");
- return if $self->{dry_run};
$LIVE->{spawn($cmd, undef, $opt)} = [ \&fp_done, $self, $cmd,
$cb, @arg ];
}
my $cmd = [ @{$self->{-torsocks}}, @git,
fetch_args($self->{lei}, $opt), $rn ];
push @$cmd, '-P' if $self->{lei}->{prune}; # --prune-tags implied
- start_cmd($self, $cmd, $opt, $fini);
+ my $run_puh = PublicInbox::OnDestroy->new($$, \&run_puh, $self, $fini);
+ start_cmd($self, $cmd, $opt, $run_puh);
}
sub fgrp_enqueue {
"$self->{dst}$ref";
}
}
- start_cmd($self, $cmd, $opt, $fini);
+ start_cmd($self, $cmd, $opt, PublicInbox::OnDestroy->new($$,
+ \&run_puh, $self, $fini));
}
if (!$self->{-is_epoch} && $lei->{opt}->{'inbox-config'} =~
/\A(?:always|v1)\z/s) {
ft_rename($ft, "$dn/$bn", 0666);
}
+sub run_next_puh {
+ my ($self) = @_;
+ my $puh = shift @{$self->{-puh_todo}} // return delete($self->{-fini});
+ 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_puh {
+ my ($self, $fini) = @_;
+ $self->{-fini} = $fini;
+ @{$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) = @_;
$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};
+ local @PUH;
+ if (defined(my $puh = $lei->{opt}->{'post-update-hook'})) {
+ require Text::ParseWords;
+ @PUH = map { [ Text::ParseWords::shellwords($_) ] } @$puh;
+ }
eval {
my $ic = $lei->{opt}->{'inbox-config'} //= 'always';
$ic =~ /\A(?:v1|v2|always|never)\z/s or die <<"";