diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:31:53 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:38:57 +0000 |
commit | c7d272cdf4f29ea632ddca2349fcff09295dca97 (patch) | |
tree | 6e8eae6e32e0b34101c1d7c53d2f7b84029aec2e /lib/PublicInbox | |
parent | 8d22b26f24c55545709023bc6df9a7136713f9d4 (diff) | |
download | public-inbox-c7d272cdf4f29ea632ddca2349fcff09295dca97.tar.gz |
We must not make permanent changes to the FS if --dry-run is in use.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 18 |
1 files 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"; |