Skip to content

Commit

Permalink
maintainers/scripts: improve github handle checker
Browse files Browse the repository at this point in the history
Now also finds name-clashes for github handles who never contributed to nixpkgs
before. Also deals with too many request errors.
  • Loading branch information
Profpatsch committed Mar 4, 2018
1 parent aa47bac commit a2c708c
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions maintainers/scripts/check-maintainer-github-handles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,61 @@

set -e

# checks whether a user handle can be found on github
# nixpkgs='<nixpkgs>'
# if [ -n "$1" ]; then

function checkCommits {
local user="$1"
local tmp=$(mktemp)
curl --silent -w "%{http_code}" \
"https://github.com/NixOS/nixpkgs/commits?author=$user" \
> "$tmp"
# the last line of tmp contains the http status
local status=$(tail -n1 "$tmp")
local ret=
case $status in
200) if <"$tmp" grep -i "no commits found" > /dev/null; then
ret=1
else
ret=0
fi
;;
# because of github’s hard request limits, this can take some time
429) sleep 2
printf "."
checkCommits "$user"
ret=$?
;;
*) printf "BAD STATUS: $(tail -n1 $tmp) for %s\n" "$user"; ret=1
ret=1
;;
esac
rm "$tmp"
return $ret
}
export -f checkCommits

function checkUser {
local user="$1"
local status=
status="$(curl --silent --head "https://github.com/${user}" | grep Status)"
printf "%s\t\t\t\t%s\n" "$status" "$user"
# checks whether a user handle can be found on github
if [[ "$status" =~ 404 ]]; then
printf "%s\t\t\t\t%s\n" "$status" "$user"
# checks whether the user handle has any nixpkgs commits
elif checkCommits "$user"; then
printf "OK!\t\t\t\t%s\n" "$user"
else
printf "No Commits!\t\t\t%s\n" "$user"
fi
}
export -f checkUser

# output the maintainers set as json
# and filter out the github username of each maintainer (if it exists)
# then check 100 at the same time
# then check some at the same time
nix-instantiate -A lib.maintainers --eval --strict --json \
| jq -r '.[]|.github' \
| parallel -j100 checkUser
| jq -r '.[]|.github|select(.)' \
| parallel -j5 checkUser

# parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a"

0 comments on commit a2c708c

Please sign in to comment.