diff options
author | Eric Wong <e@80x24.org> | 2022-10-04 19:12:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-10-05 20:24:44 +0000 |
commit | a002384a74382df2649d6a1f8dfba4f291af032e (patch) | |
tree | 1106206df2c10fc21adec29b1c3dcbcff9075d3d /lib/PublicInbox/Inbox.pm | |
parent | a93c7e471ca70bdb476c2285cf894e319b38f160 (diff) | |
download | public-inbox-a002384a74382df2649d6a1f8dfba4f291af032e.tar.gz |
We'll be using these functions for serving coderepos natively without cgit.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 8ac7eb30..3532bb58 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -181,33 +181,18 @@ sub over { } // ($req ? croak("E: $@") : undef); } -sub try_cat { - my ($path) = @_; - open(my $fh, '<', $path) or return ''; - local $/; - <$fh> // ''; -} - -sub cat_desc ($) { - my $desc = try_cat($_[0]); - local $/ = "\n"; - chomp $desc; - utf8::decode($desc); - $desc =~ s/\s+/ /smg; - $desc eq '' ? undef : $desc; -} - sub description { my ($self) = @_; - ($self->{description} //= cat_desc("$self->{inboxdir}/description")) // + ($self->{description} //= + PublicInbox::Git::cat_desc("$self->{inboxdir}/description")) // '($INBOX_DIR/description missing)'; } sub cloneurl { my ($self) = @_; $self->{cloneurl} // do { - my $s = try_cat("$self->{inboxdir}/cloneurl"); - my @urls = split(/\s+/s, $s); + my @urls = split(/\s+/s, + PublicInbox::Git::try_cat("$self->{inboxdir}/cloneurl")); scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef; } // []; } |