Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

releng/version.sh: fix git-based version detection #589

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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