2024-07-03 23:35:52 +02:00
|
|
|
set -euo pipefail
|
|
|
|
|
2024-10-05 12:07:34 +02:00
|
|
|
if [[ $# -lt 1 ]]; then
|
|
|
|
echo "Usage: git tcommit [-]<hours>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-07-03 23:35:52 +02:00
|
|
|
HOUR_SHIFT="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [[ $HOUR_SHIFT == -* ]]; then
|
|
|
|
HOUR_SHIFT="${HOUR_SHIFT#*-}"
|
|
|
|
OPERATOR="-"
|
|
|
|
else
|
|
|
|
OPERATOR="+"
|
|
|
|
fi
|
|
|
|
|
|
|
|
DATE=$(date -d "now ${OPERATOR} ${HOUR_SHIFT} hours")
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo "Commiting with date: ${DATE} (${OPERATOR}${HOUR_SHIFT}h)"
|
|
|
|
read -rp "Do you want to proceed? (y/n) " yn
|
|
|
|
|
|
|
|
case $yn in
|
|
|
|
[yY] )
|
|
|
|
break;;
|
|
|
|
[nN] )
|
|
|
|
exit;;
|
|
|
|
* ) echo invalid response;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
export GIT_COMMITTER_DATE="${DATE}"
|
|
|
|
export GIT_AUTHOR_DATE="${DATE}"
|
|
|
|
|
|
|
|
git commit "$@"
|