Skip to content

Commit

Permalink
tools/gitlog2version.sh: only consider BASE after we get DESC success…
Browse files Browse the repository at this point in the history
…fully (and abort if there is no common BASE) [networkupstools#1949]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 30, 2024
1 parent 2023b70 commit c41fe43
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tools/gitlog2version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ getver_git() {
# or "upstream/master", etc.) for resulting version discovery to make sense.
[ x"${NUT_VERSION_GIT_TRUNK-}" != x ] || NUT_VERSION_GIT_TRUNK=master

# How much of the known trunk history is in current HEAD?
# e.g. all of it when we are on that branch or PR made from its tip,
# some of it if looking at a historic snapshot, or nothing if looking
# at the tagged commit (it is the merge base for itself and any of
# its descendants):
BASE="`git merge-base HEAD "${NUT_VERSION_GIT_TRUNK}"`"

# By default, only annotated tags are considered
ALL_TAGS_ARG=""
if [ x"${NUT_VERSION_GIT_ALL_TAGS-}" = xtrue ] ; then ALL_TAGS_ARG="--tags" ; fi
Expand All @@ -139,6 +132,14 @@ getver_git() {
# echo "${DESC}" | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,'
if [ x"${DESC}" = x ] ; then echo "$0: FAILED to 'git describe' this codebase" >&2 ; return ; fi

# How much of the known trunk history is in current HEAD?
# e.g. all of it when we are on that branch or PR made from its tip,
# some of it if looking at a historic snapshot, or nothing if looking
# at the tagged commit (it is the merge base for itself and any of
# its descendants):
BASE="`git merge-base HEAD "${NUT_VERSION_GIT_TRUNK}"`" || BASE=""
if [ x"${BASE}" = x ] ; then echo "$0: FAILED to get a git merge-base of this codebase vs. '${NUT_VERSION_GIT_TRUNK}'" >&2 ; DESC=""; return ; fi

# Nearest (annotated by default) tag preceding the HEAD in history:
TAG="`echo "${DESC}" | sed 's/-[0-9][0-9]*-g[0-9a-fA-F][0-9a-fA-F]*$//'`"

Expand Down

0 comments on commit c41fe43

Please sign in to comment.