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.
This commit is contained in:
Alexander Amelkin 2017-02-07 14:06:47 +03:00 committed by Zdenek Styblik
parent 497f7767cd
commit ba01dc84b4
2 changed files with 12 additions and 2 deletions

View File

@ -1,8 +1,8 @@
dnl dnl
dnl autoconf for ipmitool dnl autoconf for ipmitool
dnl dnl
m4_define([git_suffix], m4_esyscmd_s(git describe --always --dirty=wc 2>/dev/null || echo git_snapshot)) m4_define([git_suffix], m4_esyscmd_s(./csv-revision))
AC_INIT([ipmitool], [1.8.18.git_suffix]) AC_INIT([ipmitool], [1.8.18git_suffix])
AC_CONFIG_SRCDIR([src/ipmitool.c]) AC_CONFIG_SRCDIR([src/ipmitool.c])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([foreign]) AM_INIT_AUTOMAKE([foreign])

10
csv-revision Executable file
View File

@ -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
)