From bbccb5f1d90bf9605fc8473cb9f01bc453a82bf9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 2 Nov 2023 09:35:34 +0000 Subject: io: introduce write_file helper sub This is pretty convenient way to create files for diff generation in both WWW and lei. The test suite should also be able to take advantage of it. --- lib/PublicInbox/LeiRediff.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/LeiRediff.pm') diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm index fdff4b4b..35728330 100644 --- a/lib/PublicInbox/LeiRediff.pm +++ b/lib/PublicInbox/LeiRediff.pm @@ -114,12 +114,9 @@ EOM if (!$rw->{-tmp}) { my $d = "$self->{rdtmp}/for_tree.git"; -d $d or PublicInbox::Import::init_bare($d); - my $f = "$d/objects/info/alternates"; # always overwrite - open my $fh, '>', $f or die "open $f: $!"; - for my $git (@{$self->{gits}}) { - print $fh $git->git_path('objects'),"\n"; - } - close $fh or die "close $f: $!"; + # always overwrite + PublicInbox::IO::write_file '>', "$d/objects/info/alternates", + map { $_->git_path('objects')."\n" } @{$self->{gits}}; $rw = PublicInbox::Git->new($d); } my $w = popen_wr(['git', "--git-dir=$rw->{git_dir}", -- cgit v1.2.3-24-ge0c7