Reputation: 527
I want to sync month by month to the last 12 months of commits of a repo in order to compare them. So far I have this:
for i in {12..1}; do
$(git rev-list --before "$(date -d "$(date +%Y-%m-01) -$i months" +%Y-%m)-01" -n 01 HEAD); done
This goes back monthly from the current time (so if I run it at 4:00 today it will first give me the commit closest to 4:00 12 months ago etc.).
Is there a way for git to use a constant time value, so that regardless of when I run the script it will go back monthly and report the commit closest to 12:00 or some other time?
thanks!
Upvotes: 0
Views: 1084
Reputation: 467371
Does the following do what you want?
#!/bin/bash
for i in {12..1}
do
CURRENT_DATE=$(date +%Y-%m-%d)
PAST_DATE="$(date -d "$CURRENT_DATE - $i months" "+%Y-%m-%d 12:00:00")"
git rev-list --before "$PAST_DATE" -n 1 HEAD
done
Upvotes: 1