about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-09-08 22:41:01 +0000
committerEric Wong <e@80x24.org>2016-09-08 22:41:01 +0000
commit35616acdf83e934f2de518402900a6849108ad01 (patch)
treefa95bd855dd9e607ae9a93e86e801f17eaaeafec /lib/PublicInbox/Import.pm
parentaac5361cf9f2d71bc1429e909f8664b0abbe31ae (diff)
downloadpublic-inbox-35616acdf83e934f2de518402900a6849108ad01.tar.gz
We will be reusing this in the next commit, too.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 09dd38d0..083fb1bc 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -204,6 +204,14 @@ sub add {
         $self->{tip} = ":$commit";
 }
 
+sub run_die ($$) {
+        my ($cmd, $env) = @_;
+        my $pid = spawn($cmd, $env, undef);
+        defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
+        waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
+        $? == 0 or die join(' ', @$cmd) . " failed: $?\n";
+}
+
 sub done {
         my ($self) = @_;
         my $w = delete $self->{out} or return;
@@ -222,19 +230,10 @@ sub done {
         if ($nchg && !$ENV{FAST}) {
                 my $index = "$git_dir/ssoma.index";
                 my $env = { GIT_INDEX_FILE => $index };
-                my @rt = (@cmd, qw(read-tree -m -v -i), $self->{ref});
-                $pid = spawn(\@rt, $env, undef);
-                defined $pid or die "spawn read-tree failed: $!";
-                waitpid($pid, 0) == $pid or die 'read-tree did not finish';
-                $? == 0 or die "failed to update $git_dir/ssoma.index: $?\n";
+                run_die([@cmd, qw(read-tree -m -v -i), $self->{ref}], $env);
         }
         if ($nchg) {
-                $pid = spawn([@cmd, 'update-server-info'], undef, undef);
-                defined $pid or die "spawn update-server-info failed: $!\n";
-                waitpid($pid, 0) == $pid or
-                        die 'update-server-info did not finish';
-                $? == 0 or die "failed to update-server-info: $?\n";
-
+                run_die([@cmd, 'update-server-info'], undef);
                 eval {
                         require PublicInbox::SearchIdx;
                         my $inbox = $self->{inbox} || $git_dir;