diff options
author | Eric Wong <e@80x24.org> | 2017-02-11 00:41:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-02-11 01:08:08 +0000 |
commit | 60f38818f2dbc76e20041cf1b01e2baf3322a1f1 (patch) | |
tree | 716820a77859e878a66836309aeefd946b009c5b /lib/PublicInbox/Repo.pm | |
parent | 416ba2fdab4f6de20ad7ec3656a057bb01b17339 (diff) | |
download | public-inbox-60f38818f2dbc76e20041cf1b01e2baf3322a1f1.tar.gz |
This improves startup speed at the cost of CoW-friendliness for long-lived daemons (which can be fixed, later).
Diffstat (limited to 'lib/PublicInbox/Repo.pm')
-rw-r--r-- | lib/PublicInbox/Repo.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/PublicInbox/Repo.pm b/lib/PublicInbox/Repo.pm index 812b1071..e53d6975 100644 --- a/lib/PublicInbox/Repo.pm +++ b/lib/PublicInbox/Repo.pm @@ -6,10 +6,42 @@ package PublicInbox::Repo; use strict; use warnings; +use PublicInbox::Config; sub new { my ($class, $opts) = @_; bless $opts, $class; } +sub description { + my ($self) = @_; + my $desc = $self->{description}; + return $desc if defined $desc; + $desc = PublicInbox::Config::try_cat("$self->{path}/description"); + local $/ = "\n"; + chomp $desc; + $desc =~ s/\s+/ /smg; + $desc = '($GIT_DIR/description missing)' if $desc eq ''; + $self->{description} = $desc; +} + +sub desc_html { + my ($self) = @_; + $self->{desc_html} ||= + PublicInbox::Hval->utf8($self->description)->as_html; +} + +sub cloneurl { + my ($self) = @_; + my $url = $self->{cloneurl}; + return $url if $url; + if ($self->{vcs} eq 'git') { + $url = PublicInbox::Config::try_cat("$self->{path}/cloneurl"); + $url = [ split(/\s+/s, $url) ]; + local $/ = "\n"; + chomp @$url; + } + $self->{cloneurl} = $url; +} + 1; |