user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH] lei_store: alternative unconfigured "git var" workaround
@ 2021-01-02  8:32 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-01-02  8:32 UTC (permalink / raw)
  To: meta

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 | 4 +---
 t/lei.t                     | 2 ++
 t/lei_store.t               | 2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index 7c62ffea..a23efed5 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -54,9 +54,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 690878ce..5ad82f5d 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -24,6 +24,8 @@ 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';
diff --git a/t/lei_store.t b/t/lei_store.t
index bcebde8e..c9360f8f 100644
--- a/t/lei_store.t
+++ b/t/lei_store.t
@@ -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'));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-02  8:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02  8:32 [PATCH] lei_store: alternative unconfigured "git var" workaround Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ http://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git