From e7dc3224ad0b497da6ef242e3a9c612c5702514e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Feb 2017 23:26:01 +0000 Subject: repobrowse: memoize git symbolic-ref resolution The "HEAD" symbolic ref is rarely changed, so memoize it for now and avoid exposing it in URLs. --- lib/PublicInbox/Repo.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/PublicInbox/Repo.pm') diff --git a/lib/PublicInbox/Repo.pm b/lib/PublicInbox/Repo.pm index ceebe5c4..f0cb4b3d 100644 --- a/lib/PublicInbox/Repo.pm +++ b/lib/PublicInbox/Repo.pm @@ -46,4 +46,15 @@ sub cloneurl { $self->{cloneurl} = $url; } +sub tip { + my ($self) = @_; + $self->{-tip} ||= do { + if ($self->{vcs} eq 'git') { + my $t = $self->{git}->qx(qw(symbolic-ref --short HEAD)); + chomp $t; + $t; + } + }; +} + 1; -- cgit v1.2.3-24-ge0c7