Skip to content

Instantly share code, notes, and snippets.

@r0qs
Last active July 25, 2023 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r0qs/05b15b809c9ad1c1a9a893a28cde969a to your computer and use it in GitHub Desktop.
Save r0qs/05b15b809c9ad1c1a9a893a28cde969a to your computer and use it in GitHub Desktop.
List Solidity documentation translation contributors by year
#!/bin/bash
set -e
TOKEN="${1:-}"
ORG="solidity-docs"
function get_org_repos() {
local org=$1
curl -sL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$org/repos | jq --raw-output '.[] | select(.name != ".github") | .name'
}
function clone_repo() {
local repo=$1
git clone git@github.com:solidity-docs/$repo
(
cd $repo
git remote add english git@github.com:ethereum/solidity.git
git fetch english develop
)
}
function list_contributors() {
local repo=$1
local current=2023
(
cd $repo
# year of the first commit
since=$(git log --reverse --date="format:%Y" --format="format:%ad" | head -n 1)
if (( $since < 2014 )); then
since=2014
fi
echo "---- $repo ----" >&2
for year in $(seq $since $current)
do
local until=$(( year + 1 ))
username_list=$(
git shortlog --perl-regexp --author="^((?!soldocsbot).*)$" \
--since="$year" --until="$until" --format="%aN;%aE" "english/develop..HEAD" \
-- "docs/*" | sed -rn 's/[[:space:]]*(.+?);(.+?)/\1 - \2/p' | uniq
)
if [[ -n "$username_list" ]]; then
echo "* $year to $until:" >&2
echo "$username_list" | sort -u
echo
fi
done
echo
)
}
repos=$(get_org_repos $ORG)
if [[ "$1" == "init" ]]; then
echo "Initializing repos"
for repo in $repos; do
if [ ! -d "$(pwd)/$repo" ]; then
clone_repo $repo
fi
done
fi
for repo in $repos; do
# ignoring empty documentation repo
if [[ $repo != "ur-urdu" ]]; then
list_contributors $repo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment