]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_store: alternative unconfigured "git var" workaround
authorEric Wong <e@80x24.org>
Sat, 2 Jan 2021 08:32:04 +0000 (08:32 +0000)
committerEric Wong <e@80x24.org>
Sat, 2 Jan 2021 19:38:21 +0000 (19:38 +0000)
While the changes to git->qx/git->popen from commit 171a9c24022ad7ef
will be useful for the lei daemon, hiding git error messages from
actual users is probably wrong and we'll just localize GIT_*
vars for testing.

lib/PublicInbox/LeiStore.pm
t/lei.t
t/lei_store.t

index a3decf5fe74e67be609320250718c9949808454f..07a3198aef85f0109ebbb046e5d3029c255b78e5 100644 (file)
@@ -51,9 +51,7 @@ sub git_epoch_max  {
 
 sub git_ident ($) {
        my ($git) = @_;
-       open my $null, '>', '/dev/null' or die "open /dev/null: $!";
-       my $opt = { 2 => $null };
-       chomp(my $i = $git->qx(qw(var GIT_COMMITTER_IDENT), undef, $opt));
+       chomp(my $i = $git->qx(qw(var GIT_COMMITTER_IDENT)));
        warn "$git->{git_dir} GIT_COMMITTER_IDENT failed\n" if $?;
        $i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ ? ($1, $2) :
                ('lei user', 'x@example.com')
diff --git a/t/lei.t b/t/lei.t
index 41638950b75d7e92909ed3349f72cb73fad386d4..6f6a58887040df0a7b9652d97592fa1ffc5c8fd0 100644 (file)
--- a/t/lei.t
+++ b/t/lei.t
@@ -23,6 +23,9 @@ my $lei = sub {
 my ($home, $for_destroy) = tmpdir();
 delete local $ENV{XDG_DATA_HOME};
 delete local $ENV{XDG_CONFIG_HOME};
+local $ENV{GIT_COMMITTER_EMAIL} = 'lei@example.com';
+local $ENV{GIT_COMMITTER_NAME} = 'lei user';
+local $ENV{XDG_RUNTIME_DIR} = "$home/xdg_run";
 local $ENV{HOME} = $home;
 local $ENV{FOO} = 'BAR';
 mkdir "$home/xdg_run", 0700 or BAIL_OUT "mkdir: $!";
index bcebde8e0f9a5606d8445d27fb41fc404d9a21bf..c9360f8f08218f7da7c111515df7715e13780b3a 100644 (file)
@@ -12,6 +12,8 @@ require_ok 'PublicInbox::ExtSearch';
 my ($home, $for_destroy) = tmpdir();
 my $opt = { 1 => \(my $out = ''), 2 => \(my $err = '') };
 my $store_dir = "$home/lst";
+local $ENV{GIT_COMMITTER_EMAIL} = 'lei@example.com';
+local $ENV{GIT_COMMITTER_NAME} = 'lei user';
 my $lst = PublicInbox::LeiStore->new($store_dir, { creat => 1 });
 ok($lst, '->new');
 my $smsg = $lst->add_eml(eml_load('t/data/0001.patch'));