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 <morrone2@llnl.gov>
Reviewed-on: http://review.whamcloud.com/509
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Brian J. Murrell <brian@whamcloud.com>
Reviewed-by: Christopher J. Morrone <chris.morrone.llnl@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
}
+# "git describe" will just return a tag name if the current commit is
+# tagged. Otherwise, the output will look something like this:
+#
+# <tag name>-<commits beyong tag>-g<hash>
+#
+# 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;