From f7da7fa0c3ab40b79a2358861831b925d2cb5a6b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 3 Mar 2018 22:35:00 -0500 Subject: Revert "Revert "Convert maintainer file entries to attributes, add github handles"" --- .../scripts/check-maintainer-github-handles.sh | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 maintainers/scripts/check-maintainer-github-handles.sh (limited to 'maintainers/scripts/check-maintainer-github-handles.sh') diff --git a/maintainers/scripts/check-maintainer-github-handles.sh b/maintainers/scripts/check-maintainer-github-handles.sh new file mode 100755 index 0000000000000..879a2e452cb33 --- /dev/null +++ b/maintainers/scripts/check-maintainer-github-handles.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p jq parallel + +# Example how to work with the `lib.maintainers` attrset. +# Can be used to check whether all user handles are still valid. + +set -e + +# 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)" + # 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 some at the same time +nix-instantiate -A lib.maintainers --eval --strict --json \ + | jq -r '.[]|.github|select(.)' \ + | parallel -j5 checkUser + +# parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a" -- cgit 1.4.1