From 9fe8c43437ea801bdadbd31b83a473818d7446da Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 6 Dec 2011 23:04:15 +0100 Subject: [PATCH] Pass the abbreviated Git revision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The abbreviated Git revision hash (e.g. "267480b") is typically contained in ‘gitTag’ as well, but the latter can contain other elements as well, e.g., the delta to the closest tag. That may be undesirable in version strings, so this is an alternative. --- src/lib/Hydra/Helper/AddBuilds.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 172db719..7a20599a 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -401,12 +401,15 @@ sub fetchInputGit { } # For convenience in producing readable version names, pass the - # number of commits in the history of this revision (‘revCount‘) - # and the output of git-describe (‘gitTag’). + # number of commits in the history of this revision (‘revCount’) + # the output of git-describe (‘gitTag’), and the abbreviated + # revision (‘shortRev’). my $revCount = `git rev-list $revision | wc -l`; chomp $revCount; die "git rev-list failed" if $? != 0; my $gitTag = `git describe --always $revision`; chomp $gitTag; die "git describe failed" if $? != 0; + my $shortRev = `git rev-parse --short $revision`; chomp $shortRev; + die "git rev-parse failed" if $? != 0; return { uri => $uri @@ -415,6 +418,7 @@ sub fetchInputGit { , revision => $revision , revCount => int($revCount) , gitTag => $gitTag + , shortRev => $shortRev }; } @@ -634,6 +638,7 @@ sub inputsToArgs { (defined $alt->{revision} ? "; rev = \"" . $alt->{revision} . "\"" : "") . (defined $alt->{revCount} ? "; revCount = " . $alt->{revCount} . "" : "") . (defined $alt->{gitTag} ? "; gitTag = \"" . $alt->{gitTag} . "\"" : "") . + (defined $alt->{shortRev} ? "; shortRev = \"" . $alt->{shortRev} . "\"" : "") . (defined $alt->{version} ? "; version = \"" . $alt->{version} . "\"" : "") . ";}" );