strace/copyright-year-gen
Dmitry V. Levin c4c993b642 build: use more traditional git options
The support of --no-patch alias to -s option in "git diff" and related
git commands was added in git v1.8.4.

* copyright-year-gen: Use "git show -s" instead of "git show --no-patch".
* file-date-gen: Use "git log -s" instead of "git log --no-patch".

Closes: https://github.com/strace/strace/issues/80
2018-11-24 01:22:13 +00:00

35 lines
594 B
Bash
Executable File

#! /bin/sh
: ${YEAR_FILE:=$1}
: ${DEFAULT_YEAR:=$2}
LC_TIME=C; export LC_TIME
year=
[ -n "${YEAR_FILE}" ] || {
echo >&2 "$0 $(dirname "$0")/.year [DEFAULT_YEAR]"
exit 1
}
[ -f "${YEAR_FILE}" ] && year="$(cat "${YEAR_FILE}")"
[ -n "${year}" ] ||
year="$(date -u +%Y -d "$(git show -s --format=format:%cD)")"
[ -n "${year}" ] ||
year="${DEFAULT_YEAR}"
[ -n "${year}" ] ||
[ -z "${SOURCE_DATE_EPOCH-}" ] ||
year="$(date -u +%Y -d "@${SOURCE_DATE_EPOCH}")"
[ -n "${year}" ] ||
year="$(date -u +%Y)"
[ -n "${year}" ] || {
echo >&2 'Undefined year.'
exit 1
}
printf "%s" "${year}"