Skip to content

Commit

Permalink
releng/version.sh: fix git-based version detection
Browse files Browse the repository at this point in the history
1. Correct typo: --abbrev-rev -> --abbrev-ref
2. Limit repository search to the current directory

Fixes: #588.
  • Loading branch information
ahesford committed Feb 4, 2024
1 parent c83f534 commit dae859d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions releng/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ usage() {
EOF
}

detect_version() {
# This should always run in a subshell because it manipulates the environment
detect_version() (
# Do not allow git to walk past the ZFSBootMenu tree to find a repository
export GIT_CEILING_DIRECTORIES="${PWD}/.."

# If git-describe does the job, the job is done
version="$(git describe --tags HEAD 2>/dev/null)" || version=""

Expand All @@ -32,7 +36,7 @@ detect_version() {
fi

# Otherwise, use git-rev-parse if possible
if branch="$(git rev-parse --abbrev-rev HEAD 2>/dev/null)"; then
if branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"; then
case "${branch}" in
v[0-9]*) branch="${branch#v}"
esac
Expand Down Expand Up @@ -75,7 +79,7 @@ detect_version() {
# There is apparently no version
echo "UNKNOWN"
return 1
}
)

update_version() {
version="${1?a version is required}"
Expand Down

0 comments on commit dae859d

Please sign in to comment.