From c256ddc4dd6c4150fe6e80c0dc2e9e13a66866f8 Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Wed, 25 Jul 2012 15:03:37 -0500 Subject: Include "git describe" version string in %git output. --- lib/Crawl/Bot/Plugin/Commit.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Crawl/Bot/Plugin/Commit.pm b/lib/Crawl/Bot/Plugin/Commit.pm index 8867aac..238f234 100644 --- a/lib/Crawl/Bot/Plugin/Commit.pm +++ b/lib/Crawl/Bot/Plugin/Commit.pm @@ -61,7 +61,9 @@ sub said { my $abbr = substr($commit->{hash}, 0, 12); my $pl = ($commit->{nfiles} == 1 ? "" : "s"); - $self->say(@keys, "$commit->{author} * r$abbr: $commit->{subject} " + my $rev = $commit->{revname} || "r$abbr"; + + $self->say(@keys, "$commit->{author} * $rev: $commit->{subject} " . "($commit->{date}, $commit->{nfiles} file$pl, " . "$commit->{nins}+ $commit->{ndel}-) " . "https://gitorious.org/crawl/crawl/commit/$abbr" @@ -130,6 +132,14 @@ sub parse_commit { my $info = ; CORE::close(F) or return undef; + my $revname; + + if (CORE::open(F, "-|:encoding(UTF-8)", qw(git describe), $rev)) { + $revname = ; + $revname =~ s/\n.*//; + CORE::close(F); + } + $info =~ /(.*?)\x00(.*?)\x00(.*?)\x00(.*?)\x00(.*?)\x00(.*)/s or return undef; my ($hash, $author, $subject, $body, $date, $stat) = ($1, $2, $3, $4, $5, $6); @@ -146,6 +156,7 @@ sub parse_commit { nfiles => $nfiles, nins => $nins, ndel => $ndel, + revname => $revname, }; } -- cgit v1.2.3