about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-16 21:53:07 +0000
committerEric Wong <e@80x24.org>2019-01-19 03:34:54 +0000
commit8d1766ef6c1ed2a390fe0313f9b8e34475c1d874 (patch)
treed8c75c5f2dced9d2da551ec9c25fe3373f0cde8e
parent53ac5b18f6f124fe33bf6736aac0b8c85a0d0d1b (diff)
downloadpublic-inbox-8d1766ef6c1ed2a390fe0313f9b8e34475c1d874.tar.gz
For redundancy and centralization resistance.
-rw-r--r--lib/PublicInbox/Git.pm28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 9676086f..a270180c 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -202,19 +202,33 @@ sub packed_bytes {
 
 sub DESTROY { cleanup(@_) }
 
+sub local_nick ($) {
+        my ($self) = @_;
+        my $ret = '???';
+        # don't show full FS path, basename should be OK:
+        if ($self->{git_dir} =~ m!/([^/]+)(?:/\.git)?\z!) {
+                $ret = "/path/to/$1";
+        }
+        wantarray ? ($ret) : $ret;
+}
+
 # show the blob URL for cgit/gitweb/whatever
 sub src_blob_url {
         my ($self, $oid) = @_;
-        # blob_fmt = "https://example.com/foo.git/blob/%s"
-        if (my $bfu = $self->{blob_fmt_url}) {
-                return sprintf($bfu, $oid);
+        # blob_url_format = "https://example.com/foo.git/blob/%s"
+        if (my $bfu = $self->{blob_url_format}) {
+                return map { sprintf($_, $oid) } @$bfu if wantarray;
+                return sprintf($bfu->[0], $oid);
         }
+        local_nick($self);
+}
 
-        # don't show full FS path, basename should be OK:
-        if ($self->{git_dir} =~ m!/([^/]+)\z!) {
-                return "/path/to/$1";
+sub pub_urls {
+        my ($self) = @_;
+        if (my $urls = $self->{cgit_url}) {
+                return @$urls;
         }
-        '???';
+        local_nick($self);
 }
 
 1;