From 7e0f0d96b6c63141c879d834ebc8c648bdf5a038 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Thu, 5 May 2011 15:08:44 -0700 Subject: [PATCH] LU-278 Improve regex for output of git describe Improve the regex in version_tag-git.pl to properly parse the output then the current commit is tagged, and when the tag names are longer than just the digits used in the upstream version tags. Addition from Ned: Trim trailing newline from git describe output in the case where the current commit is tagged. Change-Id: I0a6a1b54f9e2dbd381a6d00f9dcf47d9b8b66616 Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/509 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Brian J. Murrell Reviewed-by: Christopher J. Morrone Reviewed-by: Oleg Drokin --- lustre/scripts/version_tag-git.pl | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lustre/scripts/version_tag-git.pl b/lustre/scripts/version_tag-git.pl index 4912de8..1f0dbf4 100644 --- a/lustre/scripts/version_tag-git.pl +++ b/lustre/scripts/version_tag-git.pl @@ -30,10 +30,28 @@ sub get_tag() } +# "git describe" will just return a tag name if the current commit is +# tagged. Otherwise, the output will look something like this: +# +# --g +# +# Examples: +# 2.0.59-1-g4c20b1f +# 2.0.59-1somecompany-1-g4c20b1f +# foobar-15-g2e937ca +# my $desc=`git describe --tags`; -$desc =~ /([^-]+)(?:-(.+)-(.+))?\n/; -$tag = $1; -$fcoms = $2; -$hash = $3; +if ($desc =~ /(.+?)(?:-(\d)+-g([0-9a-f]+))\n?/) { + # tag with describe info added + $tag = $1; + $fcoms = $2; + $hash = $3; +} else { + # plain tag + $tag = $desc; + chomp $tag; + $fcoms = 0; + $hash = ""; +} 1; -- 1.8.3.1