From ba01dc84b4e225c86eac3f562e629662d752040f Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Tue, 7 Feb 2017 14:06:47 +0300 Subject: [PATCH] Make git revision more descriptive The previously introduced mechanism of generating a git revision was only using the abbreviated hash. That approach doesn't give a clue whether version 1.8.18.2c99bf6 is newer or older than 1.8.18.7f8d374. The project uses tags, so `git describe` can be employed to produce an incremental revision number since the last tag. Version 1.8.18.13 is much more understandable and comparable. Howerver that doesn't answer the question "what codebase was used". To address that, the abbreviated hash should also be preserved. Hence, this commit introduces a new versioning scheme like `1.8.18.13.gee01aa5`. For git snapshots when git program is absent the version will be like `1.8.18.0.gsnapshot`. For cases when .git directory is missing (Release compilation?) the suffix part will be omitted completely yielding a version like `1.8.18`. The suffix generation has been moved to the added csv-revision script. The script is absolutely POSIX-ly correct and doesn't require XSI or any other POSIX extensions. --- configure.ac | 4 ++-- csv-revision | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 csv-revision diff --git a/configure.ac b/configure.ac index f7676c9..ad1657d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl dnl autoconf for ipmitool dnl -m4_define([git_suffix], m4_esyscmd_s(git describe --always --dirty=wc 2>/dev/null || echo git_snapshot)) -AC_INIT([ipmitool], [1.8.18.git_suffix]) +m4_define([git_suffix], m4_esyscmd_s(./csv-revision)) +AC_INIT([ipmitool], [1.8.18git_suffix]) AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([foreign]) diff --git a/csv-revision b/csv-revision new file mode 100755 index 0000000..289c133 --- /dev/null +++ b/csv-revision @@ -0,0 +1,10 @@ +#!/bin/sh + +git describe --first-parent --tags 2>/dev/null | ( + IFS=- read tag rev hash + if [ $? ] && [ -n "$rev" ]; then + echo .$rev.$hash + elif [ -d .git ]; then + echo .0.gsnapshot + fi +)