Skip to content

Instantly share code, notes, and snippets.

@kellan
Created October 25, 2024 15:13
Show Gist options
  • Save kellan/729045e476ac79171ad2d06b4bfcd9fa to your computer and use it in GitHub Desktop.
Save kellan/729045e476ac79171ad2d06b4bfcd9fa to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# who are the contributor to this repo?
#
# Check if the repository path is provided
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/repo [start_date] [end_date]"
exit 1
fi
# Set the repository path
repo_path="$1"
# Set default date range or use provided dates
start_date="${2:-2024-01-01}"
end_date="${3:-2024-12-31}"
# Navigate to the repository directory
cd "$repo_path" || { echo "Invalid repository path"; exit 1; }
# Get a list of contributors with their commit counts in the specified date range
contributors=$(git log --since="$start_date" --until="$end_date" --pretty=format:"%ae" | sort | uniq -c | sort -nr)
# Count the number of unique contributors
num_contributors=$(echo "$contributors" | wc -l)
# Output the result
echo "Number of unique contributors from $start_date to $end_date: $num_contributors"
echo
echo "Contributors and their commit counts:"
echo "$contributors"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment