1
0
Fork 0

script changes

This commit is contained in:
Arthur Khachaturov 2024-08-18 03:41:19 +03:00
parent 6e8683c725
commit 775a43810c
No known key found for this signature in database
GPG key ID: CAC2B7EB6DF45D55
6 changed files with 108 additions and 25 deletions

View file

@ -1,14 +1,53 @@
#!/bin/bash
if [ ! -d .git ]; then
if [ ! -d "./.git" ]; then
echo "missing .git dir!"
exit 1
fi
echo "Last commit: $(git log | grep 'Date' | cut -d ' ' -f 4- | head -1)"
read -r -p "Date: " date
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 commit message!"
fi
export GIT_AUTHOR_DATE="${date}"
export GIT_COMMITTER_DATE="${date}"
git "$@"
git commit -am "$@"