Created
April 1, 2024 12:53
-
-
Save ynezz/e6f4219b7be20fa0f44b0f3832c26d59 to your computer and use it in GitHub Desktop.
git-signed-commits-stats.sh
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
#!/bin/bash | |
since="${1:-1 month ago}" | |
good_signatures=0 | |
unsigned_commits=0 | |
bad_signatures=0 | |
unknown_signatures=0 | |
# Loop through each commit from the last 2 years | |
while read -r commit_hash signature_status; do | |
case $signature_status in | |
B) ((bad_signatures++)) ;; | |
N) ((unsigned_commits++)) ;; | |
E) ((unknown_signatures++)) ;; | |
G|Y|X|R) ((good_signatures++)) ;; | |
esac | |
done < <(git log --since="$since" --pretty="%H %G?") | |
total_commits=$((good_signatures + unsigned_commits + bad_signatures + unknown_signatures)) | |
if [ "$total_commits" -gt 0 ]; then | |
good_percentage=$(echo "scale=2; $good_signatures / $total_commits * 100" | bc) | |
unsigned_percentage=$(echo "scale=2; $unsigned_commits / $total_commits * 100" | bc) | |
bad_percentage=$(echo "scale=2; $bad_signatures / $total_commits * 100" | bc) | |
unknown_percentage=$(echo "scale=2; $unknown_signatures / $total_commits * 100" | bc) | |
else | |
echo "No commits found in the specified time range." | |
exit 1 | |
fi | |
echo "Total commits: $total_commits (since $since)" | |
echo "Good signatures: $good_signatures ($good_percentage%)" | |
echo "Unsigned commits: $unsigned_commits ($unsigned_percentage%)" | |
echo "Bad signatures: $bad_signatures ($bad_percentage%)" | |
echo "Unknown signature status: $unknown_signatures ($unknown_percentage%)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment