2018-06-01 17:48:03 +00:00
|
|
|
#!/usr/bin/env sh
|
2013-06-24 10:09:29 +00:00
|
|
|
# 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>
|
|
|
|
|
2018-06-01 17:48:03 +00:00
|
|
|
set -e
|
|
|
|
|
2018-01-08 09:39:45 +00:00
|
|
|
# Find the fish git directory as two levels up from script directory.
|
2018-06-01 17:48:03 +00:00
|
|
|
GIT_DIR="$( cd "$( dirname $( dirname "$0" ) )" && pwd )"
|
2017-10-05 04:28:55 +00:00
|
|
|
|
2018-08-28 15:10:10 +00:00
|
|
|
# Set the output directory as either the first param or cwd.
|
|
|
|
test -n "$1" && OUTPUT_DIR=$1/ || OUTPUT_DIR=
|
|
|
|
FBVF=${OUTPUT_DIR}FISH-BUILD-VERSION-FILE
|
2014-10-12 13:01:13 +00:00
|
|
|
DEF_VER=unknown
|
2013-06-24 10:09:29 +00:00
|
|
|
|
|
|
|
# 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"
|
2017-10-05 04:28:55 +00:00
|
|
|
elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then
|
2013-06-24 10:09:29 +00:00
|
|
|
VN="$DEF_VER"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -r $FBVF
|
|
|
|
then
|
2018-01-08 09:39:45 +00:00
|
|
|
VC=$(grep -v '^#' $FBVF | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
|
2013-06-24 10:09:29 +00:00
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
2018-01-08 09:39:45 +00:00
|
|
|
|
2018-06-01 17:48:03 +00:00
|
|
|
# Maybe output the FBVF
|
2018-01-09 06:29:34 +00:00
|
|
|
# It looks like FISH_BUILD_VERSION="2.7.1-621-ga2f065e6"
|
2013-06-24 10:09:29 +00:00
|
|
|
test "$VN" = "$VC" || {
|
2017-10-05 04:28:55 +00:00
|
|
|
echo >&2 "FISH_BUILD_VERSION=$VN"
|
2018-08-28 15:10:10 +00:00
|
|
|
echo "FISH_BUILD_VERSION=\"$VN\"" >${FBVF}
|
2013-06-24 10:09:29 +00:00
|
|
|
}
|
2018-01-08 09:39:45 +00:00
|
|
|
|
|
|
|
# Output the fish-build-version-witness.txt
|
|
|
|
# See https://cmake.org/cmake/help/v3.4/policy/CMP0058.html
|
2018-08-28 15:10:10 +00:00
|
|
|
date +%s > ${OUTPUT_DIR}fish-build-version-witness.txt
|