From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 850121FB02 for ; Mon, 28 Nov 2022 05:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613556; bh=NkRUjZrh0DVL2HbqrvEBqDqm0b0H+gRjGrt+MuKH19I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gCOCnvEjiqrFnKAwhP+X4bOeKRlAHScxZOLfpPIieHi8KQuuQJTOoETX60+VobStB 90YcxVs34WqokVZObv5XLf0L/Fw2tMZFKbeWYVsuabqkeik4g2cnYgg+YbSdWTcE74 3IWW+P9LuPxlyHKG+uPwTY1oNtWd2p9K+JCjzx0c= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 19/95] lei_mirror: set gitweb.owner from manifest Date: Mon, 28 Nov 2022 05:31:16 +0000 Message-Id: <20221128053232.291618-20-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This is mainly for coderepos, but sometimes public-inboxes get shared via cgit/gitweb, too. --- lib/PublicInbox/LeiMirror.pm | 28 +++++++++++++++++++++++----- t/www_listing.t | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index d0bc7384..5e1b1c64 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -8,7 +8,7 @@ use v5.10.1; use parent qw(PublicInbox::IPC); use IO::Uncompress::Gunzip qw(gunzip $GunzipError); use IO::Compress::Gzip qw(gzip $GzipError); -use PublicInbox::Spawn qw(popen_rd spawn); +use PublicInbox::Spawn qw(popen_rd spawn run_die); use File::Path (); use File::Temp (); use Fcntl qw(SEEK_SET O_CREAT O_EXCL O_WRONLY); @@ -303,8 +303,8 @@ EOM $want } -sub init_placeholder ($$) { - my ($src, $edst) = @_; +sub init_placeholder ($$$) { + my ($src, $edst, $owner) = @_; PublicInbox::Import::init_bare($edst); my $f = "$edst/config"; open my $fh, '>>', $f or die "open($f): $!"; @@ -318,6 +318,12 @@ sub init_placeholder ($$) { ; will not fetch updates for it unless write permission is added. ; Hint: chmod +w $edst EOM + if (defined($owner)) { + print $fh <{cur_dst} // $self->{dst}, 1); + my $dst = $self->{cur_dst} // $self->{dst}; + if (defined(my $o = $self->{-ent} ? $self->{-ent}->{owner} : undef)) { + run_die([qw(git config -f), "$dst/config", 'gitweb.owner', $o]); + } + write_makefile($dst, 1); index_cloned_inbox($self, 1); } @@ -346,6 +356,11 @@ sub v2_done { # called via OnDestroy my $mg = PublicInbox::MultiGit->new($dst, 'all.git', 'git'); $mg->fill_alternates; for my $i ($mg->git_epochs) { $mg->epoch_cfg_set($i) } + my $edst_owner = delete($self->{-owner}) // []; + while (@$edst_owner) { + my ($edst, $o) = splice(@$edst_owner); + run_die [qw(git config -f), "$edst/config", 'gitweb.owner', $o]; + } for my $edst (@{delete($self->{-read_only}) // []}) { my @st = stat($edst) or die "stat($edst): $!"; chmod($st[2] & 0555, $edst) or die "chmod(a-w, $edst): $!"; @@ -384,10 +399,13 @@ failed to extract epoch number from $src $1 + 0 == $nr or die "BUG: <$uri> miskeyed $1 != $nr"; $edst .= "/git/$nr.git"; + $m->{$key} // die "BUG: `$key' not in manifest.js.gz"; if (!$want || $want->{$nr}) { push @src_edst, $src, $edst; + my $o = $m->{$key}->{owner}; + push(@{$task->{-owner}}, $edst, $o) if defined($o); } else { # create a placeholder so users only need to chmod +w - init_placeholder($src, $edst); + init_placeholder($src, $edst, $m->{$key}->{owner}); push @{$task->{-read_only}}, $edst; push @skip, $key; } diff --git a/t/www_listing.t b/t/www_listing.t index e6bb1bda..c13d8f90 100644 --- a/t/www_listing.t +++ b/t/www_listing.t @@ -150,6 +150,8 @@ EOM undef, $opt), 'clone w/include') or diag "clone_err=$clone_err"; ok(-d "$tmpdir/incl/alt", 'alt cloned'); ok(!-d "$tmpdir/incl/v2" && !-d "$tmpdir/incl/bare", 'only alt cloned'); + is(xqx([qw(git config -f), "$tmpdir/incl/alt/config", 'gitweb.owner']), + "lorelei \xc4\x80\n", 'gitweb.owner set by -clone'); undef $td;