Last active
September 12, 2022 08:21
-
-
Save Superbil/ccb35298aac83a4ed2eed4f6a89b85a0 to your computer and use it in GitHub Desktop.
Calculate time between git commits
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
# Calculate time between git commits | |
# Update rev-list target to your range or branch | |
# ref https://stackoverflow.com/questions/22725469/calculate-time-between-git-commits | |
for ix in `git rev-list @`; do | |
# get committer date, UNIX timestamp (%ct) | |
thists=`git log $ix -n 1 --format=%ct`; | |
prevts=`git log $ix~1 -n 1 --format=%ct 2>/dev/null`; | |
if [ ! -z "$prevts" ] ; then | |
delta=$(( $thists - $prevts )); | |
# get substring of hash (#ix) | |
hash=$(echo $ix | cut -c 1-7) | |
# If want result write to file, change ; to >> output_file | |
echo $hash \ | |
`date -d @$thists +'%Y-%m-%d %H:%M:%S'` "-->" \ | |
`date -d @$prevts +'%Y-%m-%d %H:%M:%S'` " ;= " \ | |
`date -u -d @$delta +'%H:%M:%S'` ; | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment