Skip to content

Instantly share code, notes, and snippets.

@francisrstokes
Created November 8, 2024 10:47
Show Gist options
  • Save francisrstokes/5b1439b2abbb392cf480a0687c4cd2be to your computer and use it in GitHub Desktop.
Save francisrstokes/5b1439b2abbb392cf480a0687c4cd2be to your computer and use it in GitHub Desktop.
What did I work on in the last week
#!/bin/bash
# Default value for days
DAYS=7
# Check if a custom number of days is provided as an argument
if [ "$1" ]; then
DAYS=$1
fi
# Function to get the git commits for a repository
get_commits() {
local repo=$1
# Check if it's a valid git repository
if [ -d "$repo/.git" ]; then
cd "$repo" || exit
# Get the commits made in the last $DAYS days
commits=$(git log --since="$DAYS days ago" --pretty=format:"%ad: %s" --date=short)
if [ -n "$commits" ]; then
echo "=== $repo ==="
echo "$commits"
echo ""
fi
cd ..
fi
}
# Iterate over all directories in the current directory
for dir in */; do
if [ -d "$dir" ]; then
get_commits "$dir"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment