1
0
Fork 0
This commit is contained in:
Arthur Khachaturov 2024-08-27 22:18:49 +03:00
parent 8d167995c7
commit 43c9688558
No known key found for this signature in database
GPG key ID: CAC2B7EB6DF45D55
6 changed files with 38 additions and 21 deletions

53
.local/bin/scripts/gdc Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
if [ ! -d "./.git" ]; then
echo "missing .git dir!"
exit 1
fi
last_commit() {
printf "Last commit date: %s\n" "$(git log | grep 'Date' | cut -d ' ' -f 4- | head -1)"
}
help() {
echo "gdt: Commit with fake date"
echo
echo "USAGE"
echo " $0 -[dl] <git command>"
echo
echo "ARGS"
echo " -d, --date Sets commit and author date"
echo " -h, --help Prints this message"
}
die() {
echo "ERROR: $1"
echo
help >&2
exit 1
}
case "$1" in
"-d"|"--date")
shift
[ -n "$1" ] && date="$1" || die "Missing date"
shift
;;
"-h"|"--help")
help
exit
;;
*)
last_commit
exit
;;
esac
if [ "$#" -lt "1" ]; then
die "Missing date!"
fi
export GIT_AUTHOR_DATE="${date}"
export GIT_COMMITTER_DATE="${date}"
git commit "$@"