tarball: remove redundant "version" file

Use the version in Cargo.toml instead.

Print a warning if the Cargo.toml version is not a prefix of the Git
version.  This can happen legit scenarios, see 0dfc490721 (build.rs:
Use Cargo_PKG_VERSION if no version could be found, 2024-06-10)
but the next commit will fix that.

Also remove stale comments in git_version_gen.sh.
This commit is contained in:
Johannes Altmanninger
2026-01-12 10:25:17 +01:00
parent f7d9c92820
commit 92dae88f62
7 changed files with 50 additions and 44 deletions

View File

@@ -1,24 +1,21 @@
#!/bin/sh
# Originally from the git sources (GIT-VERSION-GEN)
# Presumably (C) Junio C Hamano <junkio@cox.net>
# Reused under GPL v2.0
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
set -e
# Find the fish directory as two levels up from script directory.
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
DEF_VER=unknown
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -f "$FISH_BASE_DIR"/version
then
VN=$(cat "$FISH_BASE_DIR"/version) || VN="$DEF_VER"
elif VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
:
else
VN="$DEF_VER"
version=$(
awk <"$FISH_BASE_DIR/Cargo.toml" -F'"' '$1 == "version = " { print $2 }'
)
if git_version=$(
GIT_CEILING_DIRECTORIES=$FISH_BASE_DIR/.. \
git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
if [ "$git_version" = "${git_version#"$version"}" ]; then
echo >&2 "$0: warning: Cargo.toml version '$version' is not a prefix of Git version '$git_version'"
fi
version=$git_version
fi
echo "$VN"
echo "$version"