Dmitry V. Levin
c4c993b642
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
43 lines
785 B
Bash
Executable File
43 lines
785 B
Bash
Executable File
#! /bin/sh
|
|
|
|
if [ "$1" = "-f" ]; then
|
|
shift
|
|
DATE_FORMAT="$1"
|
|
shift
|
|
fi
|
|
|
|
: ${FILE:=$1}
|
|
: ${DATE_FILE:=$(dirname "$FILE")/.$(basename "${FILE}").date}
|
|
: ${DEFAULT_DATE:=$2}
|
|
: ${DATE_FORMAT:=%Y-%m-%d}
|
|
LC_TIME=C; export LC_TIME
|
|
|
|
date=
|
|
|
|
[ -n "${FILE}" ] || {
|
|
echo >&2 "$0 $(dirname "$0")/file [$(dirname "$0")/file.date [DEFAULT_DATE]]"
|
|
exit 1
|
|
}
|
|
|
|
[ -f "${DATE_FILE}" ] && date="$(cat "${DATE_FILE}")"
|
|
|
|
[ -n "${date}" ] ||
|
|
date="$(git log -s -n 1 --format=format:%cD "${FILE}")"
|
|
|
|
[ -n "${date}" ] ||
|
|
date="${DEFAULT_DATE}"
|
|
|
|
[ -n "${date}" ] ||
|
|
[ -z "${SOURCE_DATE_EPOCH-}" ] ||
|
|
date="$(date -u -d "@${SOURCE_DATE_EPOCH}")"
|
|
|
|
[ -n "${date}" ] ||
|
|
date="$(date -u)"
|
|
|
|
[ -n "${date}" ] || {
|
|
echo >&2 'Undefined date.'
|
|
exit 1
|
|
}
|
|
|
|
exec printf "%s" $(date -u "+${DATE_FORMAT}" -d "${date}")
|