diff options
author | Eric Wong <e@80x24.org> | 2023-03-21 23:07:18 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-03-25 09:37:42 +0000 |
commit | 4873f1e033b5fb1260a3cb9c857c79dce2780983 (patch) | |
tree | 31b3d7c6a26fcadacd8be765fc8024f40eedfe8d | |
parent | 852c6ff55c8ac33882defd224fee169cb90caa26 (diff) | |
download | public-inbox-4873f1e033b5fb1260a3cb9c857c79dce2780983.tar.gz |
We'll be using this for indexing git coderepos, and switch to Perl 5.12 while we're at it since unicode_strings doesn't affect this package.
-rw-r--r-- | lib/PublicInbox/Admin.pm | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm index 11ea8f83..b34f2256 100644 --- a/lib/PublicInbox/Admin.pm +++ b/lib/PublicInbox/Admin.pm @@ -1,10 +1,10 @@ -# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> # common stuff for administrative command-line tools # Unstable internal API package PublicInbox::Admin; -use strict; +use v5.12; use parent qw(Exporter); our @EXPORT_OK = qw(setup_signals); use PublicInbox::Config; @@ -69,13 +69,19 @@ sub resolve_inboxdir { die "`$try' is not a directory\n"; } } + my $dir = resolve_git_dir($cd); + $$ver = 1 if $ver; + $dir; +} + +sub resolve_git_dir { + my ($cd) = @_; # try v1 bare git dirs my $cmd = [ qw(git rev-parse --git-dir) ]; my $fh = popen_rd($cmd, undef, {-C => $cd}); my $dir = do { local $/; <$fh> }; - close $fh or die "error in @$cmd (cwd:${\($cd // '.')}): $!\n"; + close $fh or die "error in @$cmd (cwd:${\($cd // '.')}): $?\n"; chomp $dir; - $$ver = 1 if $ver; rel2abs_collapsed($dir eq '.' ? ($cd // $dir) : $dir); } |