From d07a529eec62c374c40df8240ecf11a0c592f160 Mon Sep 17 00:00:00 2001 From: Arne Georg Gleditsch Date: Thu, 29 Nov 2007 10:09:26 +0100 Subject: Not all tags are commit objects. --- lib/LXRng/Repo/Git.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/LXRng/Repo/Git.pm b/lib/LXRng/Repo/Git.pm index 3619427..261f595 100644 --- a/lib/LXRng/Repo/Git.pm +++ b/lib/LXRng/Repo/Git.pm @@ -39,15 +39,21 @@ sub cache_key { sub _release_timestamp { my ($self, $release) = @_; - my $cinfo = $self->_git_cmd('cat-file', 'commit', $release); + my $cinfo = $self->_git_cmd('cat-file', '-t', $release); + my ($type) = <$cinfo> =~ /(\S+)/; + + return undef unless $type eq 'tag' or $type eq 'commit'; + + my $cinfo = $self->_git_cmd('cat-file', $type, $release); my $time; while (<$cinfo>) { $time = $1 if /^author .*? (\d+(?: [-+]\d+|))$/ ; $time ||= $1 if /^committer .*? (\d+(?: [-+]\d+|))$/ ; + $time ||= $1 if /^tagger .*? (\d+(?: [-+]\d+|))$/ ; } - - return $time; + + return $time || 0; } sub _use_author_timestamp { -- cgit v1.2.3