Fix: make gen-version-i.sh work with shallow clones
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 18 Oct 2023 21:28:14 +0000 (17:28 -0400)
committerMichael Jeanson <mjeanson@efficios.com>
Fri, 20 Oct 2023 15:36:04 +0000 (11:36 -0400)
commitccc24971f78f33d9a9cb63ae277882ae43c35b3f
tree6ab9e4a4aaca697e88e9a15933a5f55cc135c718
parenta3788aca531e52aedc2682b6071db9fb77a6472f
Fix: make gen-version-i.sh work with shallow clones

With a shallow git clone (a clone done with `--depth=1`),
gen-version-i.sh fails with:

    $ TOP_SRCDIR=$PWD ./src/common/gen-version-i.sh
    fatal: No names found, cannot describe anything.

The underlying git command that fails is:

    $ git describe --tags --dirty --abbrev=12
    fatal: No names found, cannot describe anything.

git-describe fails because no tags are available in the shallow clone.
Work around that by using `--always`, which makes git-describe
generate string with only the commit hash as a fallback.   In my
non-shallow clone:

    $ git describe --tags --dirty --abbrev=12 --always
    v1.2.0-3854-g0b538efadd88

And in my shallow clone:

    $ git describe --tags --dirty --abbrev=12 --always
    0b538efadd88

Change-Id: Ie1c15239497bda248c9742e74a12a14af6e32928
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Thomas Applencourt <tapplencourt@anl.gov>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11073
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/common/gen-version-i.sh
This page took 0.024305 seconds and 4 git commands to generate.