mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
version.sh: keep the short version even if there are patches on top.
Instead of reverting to 0.0.0, keep the same version number (eg. 1.2.4) but add an extra suffix with the change count, eg. 1.2.4-6-tb35d95ad7-gcb8be72e6. This avoids the problem where a small patch causes the code to report a totally different version to the server, which might change its behaviour based on version code. (The server might enable various bug workarounds since it thinks 0.0.0 is very old.) Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
This commit is contained in:
parent
0050070493
commit
c03543dbe2
@ -70,12 +70,12 @@ func TestMkversion(t *testing.T) {
|
|||||||
VERSION_XCODE="101.15.129"
|
VERSION_XCODE="101.15.129"
|
||||||
VERSION_WINRES="1,15,129,0"`},
|
VERSION_WINRES="1,15,129,0"`},
|
||||||
{"abcdef", "", 1, 2, 0, 17, `
|
{"abcdef", "", 1, 2, 0, 17, `
|
||||||
VERSION_SHORT="0.0.0"
|
VERSION_SHORT="1.2.0"
|
||||||
VERSION_LONG="0.0.0-tabcdef"
|
VERSION_LONG="1.2.0-17-tabcdef"
|
||||||
VERSION_GIT_HASH="abcdef"
|
VERSION_GIT_HASH="abcdef"
|
||||||
VERSION_EXTRA_HASH=""
|
VERSION_EXTRA_HASH=""
|
||||||
VERSION_XCODE="100.0.0"
|
VERSION_XCODE="101.2.0"
|
||||||
VERSION_WINRES="0,0,0,0"`},
|
VERSION_WINRES="1,2,0,0"`},
|
||||||
{"abcdef", "defghi", 1, 15, 0, 129, `
|
{"abcdef", "defghi", 1, 15, 0, 129, `
|
||||||
VERSION_SHORT="1.15.129"
|
VERSION_SHORT="1.15.129"
|
||||||
VERSION_LONG="1.15.129-tabcdef-gdefghi"
|
VERSION_LONG="1.15.129-tabcdef-gdefghi"
|
||||||
|
@ -8,8 +8,8 @@ set -eu
|
|||||||
# 1be01ddc6e430ca3aa9beea3587d16750efb3241-dirty
|
# 1be01ddc6e430ca3aa9beea3587d16750efb3241-dirty
|
||||||
git_hash_dirty() {
|
git_hash_dirty() {
|
||||||
(
|
(
|
||||||
cd "$1" &&
|
cd "$1"
|
||||||
x=$(git rev-parse HEAD) &&
|
x=$(git rev-parse HEAD)
|
||||||
if ! git diff-index --quiet HEAD; then
|
if ! git diff-index --quiet HEAD; then
|
||||||
x="$x-dirty"
|
x="$x-dirty"
|
||||||
fi
|
fi
|
||||||
@ -33,8 +33,8 @@ case $# in
|
|||||||
extra_hash=""
|
extra_hash=""
|
||||||
elif [ -d "$extra_hash_or_dir/.git" ]; then
|
elif [ -d "$extra_hash_or_dir/.git" ]; then
|
||||||
extra_hash=$(git_hash_dirty "$extra_hash_or_dir" HEAD)
|
extra_hash=$(git_hash_dirty "$extra_hash_or_dir" HEAD)
|
||||||
elif ! expr "$extra_hash" : "^[0-9a-f]*$"; then
|
elif ! expr "$extra_hash_or_dir" : "^[0-9a-f]*$"; then
|
||||||
echo "Invalid extra hash '$extra_hash', must be a git commit hash or path to a git repo" >&2
|
echo "Invalid extra hash '$extra_hash_or_dir', must be a git commit or path to a git repo" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
extra_hash="$extra_hash_or_dir"
|
extra_hash="$extra_hash_or_dir"
|
||||||
@ -64,7 +64,7 @@ case $# in
|
|||||||
change_count=$6
|
change_count=$6
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 [extra-git-hash-or-checkout]"
|
echo "Usage: $0 [extra-git-commitid-or-dir]"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -87,18 +87,21 @@ if expr "$minor" : "[0-9]*[13579]$" >/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
patch="$change_count"
|
patch="$change_count"
|
||||||
|
change_suffix=""
|
||||||
elif [ "$change_count" != "0" ]; then
|
elif [ "$change_count" != "0" ]; then
|
||||||
# Even minor numbers are stable builds, but stable builds are
|
# Even minor numbers are stable builds, but stable builds are
|
||||||
# supposed to have a zero change count. Therefore, we're currently
|
# supposed to have a zero change count. Therefore, we're currently
|
||||||
# describing a commit that's on a release branch, but hasn't been
|
# describing a commit that's on a release branch, but hasn't been
|
||||||
# tagged as a patch release yet. We allow these commits to build
|
# tagged as a patch release yet.
|
||||||
# for testing purposes, but force their version number to 0.0.0,
|
#
|
||||||
# to reflect that they're an unreleasable build. The git hashes
|
# We used to change the version number to 0.0.0 in that case, but that
|
||||||
# still completely describe the build commit, so we can still
|
# caused some features to get disabled due to the low version number.
|
||||||
# figure out what this build is if it escapes into the wild.
|
# Instead, add yet another suffix to the version number, with a change
|
||||||
major="0"
|
# count.
|
||||||
minor="0"
|
change_suffix="-$change_count"
|
||||||
patch="0"
|
else
|
||||||
|
# Even minor number with no extra changes.
|
||||||
|
change_suffix=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Hack for 1.1: add 1000 to the patch number. We switched from using
|
# Hack for 1.1: add 1000 to the patch number. We switched from using
|
||||||
@ -113,9 +116,9 @@ fi
|
|||||||
# policies. All that remains is to output the various vars that other
|
# policies. All that remains is to output the various vars that other
|
||||||
# code can use to embed version data.
|
# code can use to embed version data.
|
||||||
if [ -z "$extra_hash" ]; then
|
if [ -z "$extra_hash" ]; then
|
||||||
long_version_suffix="-t$short_git_hash"
|
long_version_suffix="$change_suffix-t$short_git_hash"
|
||||||
else
|
else
|
||||||
long_version_suffix="-t${short_git_hash}-g${short_extra_hash}"
|
long_version_suffix="$change_suffix-t$short_git_hash-g$short_extra_hash"
|
||||||
fi
|
fi
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
VERSION_SHORT="$major.$minor.$patch"
|
VERSION_SHORT="$major.$minor.$patch"
|
||||||
|
Loading…
Reference in New Issue
Block a user