@@ -6,18 +6,61 @@
66
77set -e
88
9−# checks whether a user handle can be found on github
9+# nixpkgs='<nixpkgs>'
10+# if [ -n "$1" ]; then
11+
12+function checkCommits {
13+ local user="$1"
14+ local tmp=$(mktemp)
15+ curl --silent -w "%{http_code}" \
16+ "https://github.com/NixOS/nixpkgs/commits?author=$user" \
17+ > "$tmp"
18+ # the last line of tmp contains the http status
19+ local status=$(tail -n1 "$tmp")
20+ local ret=
21+ case $status in
22+ 200) if <"$tmp" grep -i "no commits found" > /dev/null; then
23+ ret=1
24+ else
25+ ret=0
26+ fi
27+ ;;
28+ # because of github’s hard request limits, this can take some time
29+ 429) sleep 2
30+ printf "."
31+ checkCommits "$user"
32+ ret=$?
33+ ;;
34+ *) printf "BAD STATUS: $(tail -n1 $tmp) for %s\n" "$user"; ret=1
35+ ret=1
36+ ;;
37+ esac
38+ rm "$tmp"
39+ return $ret
40+}
41+export -f checkCommits
42+
1043function checkUser {
1144 local user="$1"
1245 local status=
1346 status="$(curl --silent --head "https://github.com/${user}" | grep Status)"
14− printf "%s\t\t\t\t%s\n" "$status" "$user"
47+ # checks whether a user handle can be found on github
48+ if [[ "$status" =~ 404 ]]; then
49+ printf "%s\t\t\t\t%s\n" "$status" "$user"
50+ # checks whether the user handle has any nixpkgs commits
51+ elif checkCommits "$user"; then
52+ printf "OK!\t\t\t\t%s\n" "$user"
53+ else
54+ printf "No Commits!\t\t\t%s\n" "$user"
55+ fi
1556}
1657export -f checkUser
1758
1859# output the maintainers set as json
1960# and filter out the github username of each maintainer (if it exists)
20−# then check 100 at the same time
61+# then check some at the same time
2162nix-instantiate -A lib.maintainers --eval --strict --json \
22− | jq -r '.[]|.github' \
23− | parallel -j100 checkUser
63+ | jq -r '.[]|.github|select(.)' \
64+ | parallel -j5 checkUser
65+
66+# parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a"