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=-3.9 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 DB48B203D5 for ; Mon, 28 Nov 2022 05:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613572; bh=5nInRM5uuFJ7a7jmzZrxqJ4smJersv0x/RK6wKdaQEI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZFa1q3wl8LKCdUBH/0x4bqqUu5HSq9onaVYK0b+JbBj0I2RXGcnTCKgMcLNWO7dNt 1ZcH0JYtOtzZikqlJF1C/xv7J7ATLBTf2rVyFbeH7StbWH2O1a4cSyQGsjQmxgqHOv ign2bvvxPvpzC2owgR9Po3CmPmBXTB9vDzWPEjAk= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 94/95] clone: support --project-list= for cgit Date: Mon, 28 Nov 2022 05:32:31 +0000 Message-Id: <20221128053232.291618-95-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: grokmirror supports it, and we also support cgit, so this should make running mirrors easier. This will be useful for scripting purposes, too. --- lib/PublicInbox/LeiMirror.pm | 39 +++++++++++++++++++++++++++++++++--- script/public-inbox-clone | 4 ++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 0508c9a8..d4b14699 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -991,6 +991,34 @@ sub dump_manifest ($$) { utime($mtime, $mtime, "$ft") or die "utime(..., $ft): $!"; } +sub dump_project_list ($$) { + my ($self, $m) = @_; + my $f = $self->{'-project-list'} // return; + my $old = PublicInbox::Git::try_cat($f); + my %new; + + open my $dh, '<', '.' or die "open(.): $!"; + chdir($self->{dst}) or die "chdir($self->{dst}): $!"; + my @local = grep { -e $_ ? ($new{$_} = undef) : 1 } split(/\n/s, $old); + chdir($dh) or die "chdir(restore): $!"; + + $new{substr($_, 1)} = 1 for keys %$m; # drop leading '/' + my @list = sort keys %new; + my @remote = grep { !defined($new{$_}) } @list; + + warn <{src}: +EOM + warn "\t", $_, "\n" for @remote; + warn <splitpath($f); + atomic_write($dn, $bn, join("\n", @list, '')); +} + # FIXME: this gets confused by single inbox instance w/ global manifest.js.gz sub try_manifest { my ($self) = @_; @@ -1104,6 +1132,7 @@ EOM warn(<{opt}->{$k} // next; $v = $default if $v eq ''; $v = "$self->{dst}/$v" if $v !~ m!\A\.{0,2}/!; $self->{"-$k"} = $v; } + local $LIVE = {}; local $TODO = {}; local $FGRP_TODO = {}; diff --git a/script/public-inbox-clone b/script/public-inbox-clone index efe0cff6..677c56c8 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -22,8 +22,12 @@ options: --quiet | -q increase verbosity (may be repeated) -C DIR chdir to specified directory EOF + +# cgit calls it `project-list', grokmirror calls it `projectslist', +# support both :/ GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@ inbox-config=s inbox-version=i objstore=s manifest=s + project-list|projectslist=s prune|p keep-going|k dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help; if ($opt->{help}) { print $help; exit };