-
-
Save petitchevalroux/d51f02ee2787b6b35be96911c8f5f4c8 to your computer and use it in GitHub Desktop.
Use this command instead of git commit to commit between two dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git commit "$@" | |
current=$(date +%s) | |
# Yesterday at 6pm UTC | |
start=$(($current - $current % 86400 - 3600 * 6)) | |
# Yesterday at midnight UTC | |
end=$(($current - $current % 86400)) | |
nextEnd=$(($end + 86399)) | |
commitDate=$(( $start + $(bc -l <<< "$(($current - $end))/$(($nextEnd - $end))*$(($end - $start))" | awk '{print int($1+0.5)}'))) | |
echo "$(date -r$start) < $(date -r$commitDate) < $(date -r$end)" | |
export GIT_COMMITTER_DATE=$commitDate; git commit --amend --date $commitDate --no-edit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment