diff options
Diffstat (limited to 'lib/PublicInbox/Fetch.pm')
-rw-r--r-- | lib/PublicInbox/Fetch.pm | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm index 198e2a60..814d6e8e 100644 --- a/lib/PublicInbox/Fetch.pm +++ b/lib/PublicInbox/Fetch.pm @@ -5,12 +5,14 @@ package PublicInbox::Fetch; use v5.12; use parent qw(PublicInbox::IPC); use URI (); -use PublicInbox::Spawn qw(popen_rd run_die spawn); +use PublicInbox::Spawn qw(popen_rd run_qx run_wait); use PublicInbox::Admin; use PublicInbox::LEI; use PublicInbox::LeiCurl; use PublicInbox::LeiMirror; +use PublicInbox::SHA qw(sha_all); use File::Temp (); +use PublicInbox::Git qw(git_exe); sub new { bless {}, __PACKAGE__ } @@ -18,10 +20,9 @@ sub remote_url ($$) { my ($lei, $dir) = @_; my $rn = $lei->{opt}->{'try-remote'} // [ 'origin', '_grokmirror' ]; for my $r (@$rn) { - my $cmd = [ qw(git config), "remote.$r.url" ]; - my $fh = popen_rd($cmd, undef, { -C => $dir, 2 => $lei->{2} }); - my $url = <$fh>; - close $fh or next; + my $cmd = [ git_exe, 'config', "remote.$r.url" ]; + my $url = run_qx($cmd, undef, { -C => $dir, 2 => $lei->{2} }); + next if $?; $url =~ s!/*\n!!s; return $url; } @@ -92,9 +93,8 @@ sub do_manifest ($$$) { sub get_fingerprint2 { my ($git_dir) = @_; - require Digest::SHA; - my $rd = popen_rd([qw(git show-ref)], undef, { -C => $git_dir }); - Digest::SHA::sha256(do { local $/; <$rd> }); + my $rd = popen_rd([git_exe, 'show-ref'], undef, { -C => $git_dir }); + sha_all(256, $rd)->digest; # ignore show-ref errors } sub writable_dir ($) { @@ -131,10 +131,10 @@ sub do_fetch { # main entry point $epoch = $nr; } else { warn "W: $edir missing remote.*.url\n"; - my $pid = spawn([qw(git config -l)], undef, - { 1 => $lei->{2}, 2 => $lei->{2} }); - waitpid($pid, 0); - $lei->child_error($?) if $?; + my $o = { -C => $edir }; + $o->{1} = $o->{2} = $lei->{2}; + run_wait([git_exe, qw(config -l)], undef, $o) + and $lei->child_error($?); } } @epochs = grep { !$skip->{$_} } @epochs if $skip; @@ -189,7 +189,7 @@ EOM my $opt = {}; # for spawn if (-d $d) { $fp2->[0] = get_fingerprint2($d) if $fp2; - $cmd = [ @$torsocks, 'git', "--git-dir=$d", + $cmd = [ @$torsocks, git_exe, "--git-dir=$d", PublicInbox::LeiMirror::fetch_args($lei, $opt)]; } else { my $e_uri = $ibx_uri->clone; |