1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-30 06:45:25 +00:00
irssi/utils/irssi-version.sh

31 lines
1009 B
Bash
Raw Normal View History

2014-05-30 23:13:46 +00:00
#!/bin/sh
2022-02-18 19:50:37 +00:00
DATE=$(GIT_DIR=$1/.git git log -1 --pretty=format:%ci HEAD 2>/dev/null)
2022-02-18 19:50:37 +00:00
VERSION_DATE=$(echo "$DATE" | cut -f 1 -d ' ' | tr -d -)
VERSION_TIME=$(echo "$DATE" | cut -f 2 -d ' ' | awk -F: '{printf "%d", $1$2}')
2014-05-30 23:13:46 +00:00
if test -z "$VERSION_DATE"; then
2022-02-18 19:50:37 +00:00
DATE=$(grep '^v' "$1"/NEWS | head -1)
VERSION_DATE=$(echo "$DATE" | cut -f 2 -d ' ' | tr -d -)
2019-07-07 22:02:53 +00:00
case $VERSION_DATE in
*xx)
2022-02-18 19:50:37 +00:00
VERSION_DATE=$(date +%Y%m%d)
2019-07-07 22:02:53 +00:00
;;
esac
2022-02-18 19:50:37 +00:00
VERSION_TIME=$(echo "$DATE" | cut -f 1 -d ' ' | tr -d v | tr .- ' ')
VERSION_TIME=$(printf %d%d%02d $VERSION_TIME 2>/dev/null | cut -c 1-4)
fi
echo "#define IRSSI_VERSION_DATE $VERSION_DATE"
echo "#define IRSSI_VERSION_TIME $VERSION_TIME"
if echo "${VERSION}" | grep -q -- -head; then
# -head version, get extra details from git if we can
2021-01-04 15:50:02 +00:00
git_version=$(GIT_DIR=$1/.git git describe --dirty --long --tags --match '[0-9]*.[0-9]*' 2>/dev/null)
if [ $? = 0 ]; then
echo "#undef PACKAGE_VERSION"
echo "#define PACKAGE_VERSION \"${git_version}\""
fi
fi