mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
25839b8c36
Correctly generate FISH_BUILD_VERSION for use in fish_version.h/cpp and fish.pc to allow `fish --version` and `echo $version` to work again. Not needing the same convoluted measures used by Makefile builds to prevent the regeneration of the fish version file when it hasn't changed. Purposely created a new `cmake_git_version_gen.sh` file so that the old `git_version_gen.sh` remains compatible with the existing Makefile build script. Same reason why `fish.pc.in` was not modified to use a lowercase variable name to match the CMAKE variable of the same name. Closes #4626
24 lines
792 B
Bash
Executable file
24 lines
792 B
Bash
Executable file
#!/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>
|
|
|
|
# Obtain directory containing this script in POSIX-compatible manner
|
|
# See https://stackoverflow.com/a/43919044/17027 (public domain)
|
|
a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a#/}/"; BASEDIR=$(cd "$a"; pwd)
|
|
# Find the fish git directory as two levels up from this directory.
|
|
GIT_DIR=$(dirname "$a")
|
|
|
|
DEF_VER=unknown
|
|
|
|
# First see if there is a version file (included in release tarballs),
|
|
# then try git-describe, then default.
|
|
if test -f version
|
|
then
|
|
VN=$(cat version) || VN="$DEF_VER"
|
|
elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then
|
|
VN="$DEF_VER"
|
|
fi
|
|
|
|
echo -n "$VN"
|