| 1 | #!/bin/bash |
| 2 | # Script that displays some interesting stats about the gitlint project (LOC, # commits, downloads, etc) |
| 3 | |
| 4 | BLUE="\033[94m" |
| 5 | NO_COLOR="\033[0m" |
| 6 | |
| 7 | title(){ |
| 8 | echo -e "$BLUE=== $1 ===$NO_COLOR" |
| 9 | } |
| 10 | |
| 11 | title Code |
| 12 | radon raw -s gitlint-core | tail -n 11 | sed 's/^ //' |
| 13 | |
| 14 | title Docs |
| 15 | echo "Markdown: $(cat docs/*.md | wc -l | tr -d " ") lines" |
| 16 | |
| 17 | title Tests |
| 18 | nr_unit_tests=$(py.test gitlint-core/ --collect-only | grep TestCaseFunction | wc -l) |
| 19 | nr_integration_tests=$(py.test qa/ --collect-only | grep TestCaseFunction | wc -l) |
| 20 | echo "Unit Tests: ${nr_unit_tests//[[:space:]]/}" |
| 21 | echo "Integration Tests: ${nr_integration_tests//[[:space:]]/}" |
| 22 | |
| 23 | title Git |
| 24 | echo "Commits: $(git rev-list --all --count)" |
| 25 | echo "Commits (main): $(git rev-list main --count)" |
| 26 | echo "First commit: $(git log --pretty="%aD" $(git rev-list --max-parents=0 HEAD))" |
| 27 | echo "Contributors: $(git log --format='%aN' | sort -u | wc -l | tr -d ' ')" |
| 28 | echo "Releases (tags): $(git tag --list | wc -l | tr -d ' ')" |
| 29 | latest_tag=$(git tag --sort=creatordate | tail -n 1) |
| 30 | echo "Latest Release (tag): $latest_tag" |
| 31 | echo "Commits since $latest_tag: $(git log --format=oneline HEAD...$latest_tag | wc -l | tr -d ' ')" |
| 32 | echo "Line changes since $latest_tag: $(git diff --shortstat $latest_tag)" |
| 33 | |
| 34 | # PyPi API: https://pypistats.org/api/ |
| 35 | title PyPi |
| 36 | info=$(curl -Ls https://pypi.python.org/pypi/gitlint/json) |
| 37 | echo "Current version: $(echo $info | jq -r .info.version)" |
| 38 | |
| 39 | title "PyPI (Downloads)" |
| 40 | overall_stats=$(curl -s https://pypistats.org/api/packages/gitlint/overall) |
| 41 | recent_stats=$(curl -s https://pypistats.org/api/packages/gitlint/recent) |
| 42 | echo "Last 6 Months: $(echo $overall_stats | jq -r '.data[].downloads' | awk '{sum+=$1} END {print sum}')" |
| 43 | echo "Last Month: $(echo $recent_stats | jq .data.last_month)" |
| 44 | echo "Last Week: $(echo $recent_stats | jq .data.last_week)" |
| 45 | echo "Last Day: $(echo $recent_stats | jq .data.last_day)" |