Created
March 7, 2025 17:50
-
-
Save zoellner/5224ec7c30f96c65af85523bd3715700 to your computer and use it in GitHub Desktop.
Get all my (or others) git commits in a repo including submodules from the past week
This file contains hidden or 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 | |
# Script to get commits from a specific author across all subrepos | |
# Usage: my-commits [author] [days] | |
# Example: my-commits "zoellner" 7 | |
AUTHOR=${1:-"zoellner"} | |
DAYS=${2:-7} | |
SINCE="$DAYS days ago" | |
echo "Getting commits by '$AUTHOR' since '$SINCE'" | |
echo "" | |
# Check current repository | |
echo "=== Current Repository ===" | |
git log --author="$AUTHOR" --since="$SINCE" --pretty=format:"%h - %s (%cd)" --date=format:"%Y-%m-%d %H:%M" 2>/dev/null | cat | |
echo "" | |
# Check if .gitmodules exists | |
if [ -f ".gitmodules" ]; then | |
echo -e "\n=== Submodules ===" | |
# Parse .gitmodules to get all submodule paths | |
grep -E "^\s*path\s*=" .gitmodules | awk '{print $3}' > /tmp/submodules.txt | |
# Check each submodule | |
for repo in $(cat /tmp/submodules.txt); do | |
if [ -d "$repo/.git" ]; then | |
echo -e "\n=== $repo ===" | |
cd $repo | |
git log --author="$AUTHOR" --since="$SINCE" --pretty=format:"%h - %s (%cd)" --date=format:"%Y-%m-%d %H:%M" 2>/dev/null | cat | |
cd - > /dev/null | |
fi | |
done | |
# Clean up | |
rm /tmp/submodules.txt | |
fi | |
echo -e "\nDone!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment