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.1 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 78932203AB for ; Mon, 28 Nov 2022 05:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613564; bh=EZrDYZDFuKRbynJcut+Hc5gVCDQbeAf1Ze+Qd2/JC9c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lao6sgo1xphj/oaidGPgU4Ct9nmz/abIY7jLBvBIujc1LJJet5yY0uxirfx6Egl4b BJEdWqChq45DbApm4P6Uq1CqhBEmTVehqQm0fyK3VJmDnBMGSE6+c2cR7A+ZT7ux5k DuOLuCw+1ggJyWG1SdIfXGnUHj++vbU2qq+JG0tM= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 56/95] lei_mirror: fix --dry-run for forkgroups Date: Mon, 28 Nov 2022 05:31:53 +0000 Message-Id: <20221128053232.291618-57-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: We must not make permanent changes to the FS if --dry-run is in use. --- lib/PublicInbox/LeiMirror.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 3220f48d..00732128 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -378,7 +378,7 @@ sub forkgroup_prep { my $dir = "$os/$fg.git"; my @cmd = ('git', "--git-dir=$dir", 'config'); my $opt = +{ map { $_ => $self->{lei}->{$_} } (0..2) }; - if (!-d $dir) { + if (!-d $dir && !$self->{dry_run}) { PublicInbox::Import::init_bare($dir); for ('repack.useDeltaIslands=true', 'pack.island=refs/remotes/([^/]+)/') { @@ -391,15 +391,17 @@ sub forkgroup_prep { $rn =~ s/\.*?(?:\.git)?\.*?\z//s; $rn =~ s![\@\{\}/:\?\[\]\^~\s\f[:cntrl:]\*]!_!isg; $rn .= '-'.substr(sha256_hex($key), 0, 16); - # --no-tags is required to avoid conflicts - for ("url=$uri", "fetch=+refs/*:refs/remotes/$rn/*", - 'tagopt=--no-tags') { - my @kv = split(/=/, $_, 2); - $kv[0] = "remote.$rn.$kv[0]"; - run_die([@cmd, @kv], undef, $opt); + unless ($self->{dry_run}) { + # --no-tags is required to avoid conflicts + for ("url=$uri", "fetch=+refs/*:refs/remotes/$rn/*", + 'tagopt=--no-tags') { + my @kv = split(/=/, $_, 2); + $kv[0] = "remote.$rn.$kv[0]"; + run_die([@cmd, @kv], undef, $opt); + } } $self->{-do_pack_refs} = 1; # likely coderepo - if (!-d $self->{cur_dst}) { + if (!-d $self->{cur_dst} && !$self->{dry_run}) { my $alt = File::Spec->rel2abs("$dir/objects"); PublicInbox::Import::init_bare($self->{cur_dst}); my $o = "$self->{cur_dst}/objects";