git contribution
xy241
sh
5 days ago
1.1 kB
2
Indexable
#!/bin/bash # Get list of all authors in the repository (master branch only) authors=$(git log master --format='%ae' | sort -u) printf "%-25s %-12s %-12s %-12s\n" "Author" "Added" "Removed" "Total" printf "%-25s %-12s %-12s %-12s\n" "$(printf '%.0s-' {1..25})" "$(printf '%.0s-' {1..12})" "$(printf '%.0s-' {1..12})" "$(printf '%.0s-' {1..12})" # Loop through each author and calculate their stats on master branch for author in $authors; do stats=$(git log master --author="$author" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2 } END { printf "%d %d %d", add, subs, add-subs }') if [ ! -z "$stats" ]; then name=$(git log master --author="$author" --format='%an' | head -n 1) read -r added removed total <<< "$stats" # Determine prefix based on total if [ "$total" -gt 0 ]; then prefix="Added" elif [ "$total" -lt 0 ]; then prefix="Removed" else prefix="Modified" fi printf "%-25s %-12s %-12s %-12s %s\n" "${name:0:25}" "$added" "$removed" "$total" "$prefix" fi done
Editor is loading...
Leave a Comment