diff options
author | Eric Wong <e@80x24.org> | 2022-10-04 19:12:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-10-05 20:24:43 +0000 |
commit | a93c7e471ca70bdb476c2285cf894e319b38f160 (patch) | |
tree | 549e02c329b4a905041a2a5d293ecca2eca1a764 /lib/PublicInbox/Git.pm | |
parent | 061d247778949c371734c6ab5e3fe1be0dced23b (diff) | |
download | public-inbox-a93c7e471ca70bdb476c2285cf894e319b38f160.tar.gz |
We'll be using this separately, elsewhere.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r-- | lib/PublicInbox/Git.pm | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 9140caea..78b47096 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -498,6 +498,15 @@ sub modified ($) { (split(/ /, <$fh> // time))[0] + 0; # integerize for JSON } +sub description { + my $desc = ''; + if (open(my $fh, '<:utf8', "$_[0]->{git_dir}/description")) { + local $/ = "\n"; + chomp($desc = <$fh> // ''); + } + $desc eq '' ? 'Unnamed repository' : $desc; +} + # for grokmirror, which doesn't read gitweb.description # templates/hooks--update.sample and git-multimail in git.git # only match "Unnamed repository", not the full contents of @@ -520,14 +529,8 @@ sub manifest_entry { chomp(my $owner = $self->qx('config', 'gitweb.owner')); utf8::decode($owner); $ent->{owner} = $owner eq '' ? undef : $owner; - my $desc = ''; - if (open($fh, '<', "$git_dir/description")) { - local $/ = "\n"; - chomp($desc = <$fh>); - utf8::decode($desc); - } - $desc = 'Unnamed repository' if $desc eq ''; - if (defined $epoch && $desc =~ /\AUnnamed repository/) { + my $desc = description($self); + if (defined $epoch && index($desc, 'Unnamed repository') == 0) { $desc = "$default_desc [epoch $epoch]"; } $ent->{description} = $desc; |