Last active
January 30, 2024 15:49
-
-
Save JaniM/759ee0152ed549f9e7d06c6654877d9a to your computer and use it in GitHub Desktop.
Scan commits by date range
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
#!/usr/bin/env bash | |
# Finds all commits in all repositories under PWD | |
# across the given time range | |
# Ex. ./commits_on_day.sh 2024-01-01 2024-01-30 | |
set -e | |
DATE="$1" | |
END_DATE="${2:-$1}" | |
# Note: .git in git submodules is actually a file | |
REPOS=$(find . -name .git -prune | sed 's/\.git//g') | |
while ! [[ "$DATE" > "$END_DATE" ]]; do | |
echo "$DATE" | |
PREV_DATE=$(date +%Y-%m-%d -d "$DATE - 1 day") | |
NEXT_DATE=$(date +%Y-%m-%d -d "$DATE + 1 day") | |
for repo in $REPOS; do ( | |
cd "$repo"; | |
RESP=$( | |
git log --pretty=format:" %ad - %an: %s" \ | |
--after="$PREV_DATE" \ | |
--until="$DATE" 2>/dev/null \ | |
|| true | |
) | |
if [ ! -z "$RESP" ]; then | |
echo " in $repo" | |
echo "$RESP" | |
fi | |
); done | |
DATE=$NEXT_DATE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment