]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: make basename more descriptive
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:52 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:57 +0000 (23:38 +0000)
This makes it easier for humans to distinguish between
"Alice/project.git" and "Bob/project.git"

lib/PublicInbox/LeiMirror.pm

index 28fef6f949de4e2253e8db4d1ae83ca4cd5f2cd0..3220f48de2f64f245ffb896b36a096fcebebfa15 100644 (file)
@@ -386,8 +386,11 @@ sub forkgroup_prep {
                }
        }
        my $key = $self->{-key} // die 'BUG: no -key';
-       my ($bn) = ($key =~ m{/([a-z0-9_,;=!\+\{\}\|][^/]*)(?:\.git)?\z}i);
-       my $rn = "$bn-".substr(sha256_hex($key), 0, 16);
+       my $rn = $key;
+       $rn =~ s!\A[\./]+!!s;
+       $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') {