summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2014-10-12 23:05:14 +0400
committerMichael Raskin <7c6f434c@mail.ru>2014-10-12 23:05:27 +0400
commit3d7583395695698d1ff277fc351b9480361f28dd (patch)
tree089d7771c0f3068b7985b1f43b7cae7d1746cc3d
parent6465d684b81d75ed42a5cdb4e50b3108e73ac031 (diff)
downloadnixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar.gz
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar.bz2
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar.lz
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar.xz
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.tar.zst
nixpkgs-3d7583395695698d1ff277fc351b9480361f28dd.zip
Update vanity counter. Now with GitHub username support
-rw-r--r--maintainers/scripts/vanity-manual-equalities.txt3
-rwxr-xr-xmaintainers/scripts/vanity.sh61
2 files changed, 62 insertions, 2 deletions
diff --git a/maintainers/scripts/vanity-manual-equalities.txt b/maintainers/scripts/vanity-manual-equalities.txt
index 392ff266e1a..9b31e9dc07c 100644
--- a/maintainers/scripts/vanity-manual-equalities.txt
+++ b/maintainers/scripts/vanity-manual-equalities.txt
@@ -1,3 +1,6 @@
 viric	viriketo@gmail.com
 Pjotr Prins	pjotr.public01@thebird.nl
 Pjotr Prins	pjotr.public05@thebird.nl
+Wouter den Breejen	wbreejen
+MarcWeber	marcweber
+Ricardo Correia	Ricardo M. Correia
diff --git a/maintainers/scripts/vanity.sh b/maintainers/scripts/vanity.sh
index 5f4d38c8145..5a1b8b08b60 100755
--- a/maintainers/scripts/vanity.sh
+++ b/maintainers/scripts/vanity.sh
@@ -3,7 +3,8 @@
 export LANG=C LC_ALL=C LC_COLLATE=C
 
 # Load git log
-git_data="$(git log | grep 'Author:' | 
+raw_git_log="$(git log)"
+git_data="$(echo "$raw_git_log" | grep 'Author:' | 
   sed -e 's/^ *Author://; s/\\//g; s/^ *//; s/ *$//; 
   s/ @ .*//; s/ *[<]/\t/; s/[>]//')"
 
@@ -15,6 +16,35 @@ maintainers="$(cat "$(dirname "$0")/../../lib/maintainers.nix" |
 git_lines="$( ( echo "$git_data"; 
     cat "$(dirname "$0")/vanity-manual-equalities.txt") | sort |uniq)"
 
+emails="$( 
+    ( echo "$maintainers" | cut -f 3; echo "$git_data" | cut -f 2 ) | 
+    sort | uniq | grep -E ".+@.+[.].+" 
+    )"
+
+fetchGithubName () {
+    commitid="$(
+        echo "$raw_git_log" | grep -B3 "Author: .*[<]$1[>]" | head -n 3 | 
+            grep '^commit ' | tail -n 1 | sed -e 's/^commit //'
+    )"
+    userid="$(
+        curl https://github.com/NixOS/nixpkgs/commit/"$commitid" 2>/dev/null |
+        grep authored -B10 | grep 'href="/' |
+        sed -re 's@.* href="/@@; s@".*@@' |
+	grep -v "/commit/"
+    )";
+    echo "$userid"
+}
+
+[ -n "$NIXPKGS_GITHUB_NAME_CACHE" ] && {
+    echo "$emails" | while read email; do 
+        line="$(grep "$email	" "$NIXPKGS_GITHUB_NAME_CACHE")"
+	[ -z "$line" ] && {
+            echo "$email	$(fetchGithubName "$email")" >> \
+                "$NIXPKGS_GITHUB_NAME_CACHE"
+        }
+    done
+}
+
 # For RDF
 normalize_name () {
 	sed -e 's/%/%25/g; s/ /%20/g; s/'\''/%27/g; s/"/%22/g;'
@@ -37,6 +67,9 @@ echo "$maintainers" | sed -re 's@(.*)\t(.*)\t(.*)@<my://name/\3>	<my://can-be>	<
 echo "$git_lines" | grep ' ' | cut -f 1 | sed -e 's@.*@<my://name/&>	<my://is-name>	<my://0>.@'
 echo "$git_lines" | grep -v ' ' | cut -f 1 | sed -e 's@.*@<my://name/&>	<my://is-name>	<my://1>.@'
 echo "$maintainers" | cut -f 2 | sed -e 's@.*@<my://name/&>	<my://is-name>	<my://0>.@'
+[ -n "$NIXPKGS_GITHUB_NAME_CACHE" ] && cat "$NIXPKGS_GITHUB_NAME_CACHE" |
+    grep -v "	$" |
+    sed -re 's@(.*)\t(.*)@<my://name/\1>	<my://at-github>	<my://github/\2>.@'
 ) | normalize_name | grep -E '<my://[-a-z]+>' | sort | uniq > "$n3"
 
 # Get transitive closure
@@ -51,6 +84,14 @@ name_list="$(
 	sed -re 's@<my://name/@@g; s@<my://@@g; s@>@@g;' | 
 	sort -k 2,3 -t '	'
 )"
+github_name_list="$(
+	"$sparql" --results=TSV --data="$n3" "
+	select ?x ?y where {
+	  ?x (<my://can-be>+ / <my://at-github>) ?y.
+        }
+	" | tail -n +2 | 
+	sed -re 's@<my://(name|github)/@@g; s@<my://@@g; s@>@@g;'
+)"
 
 # Take first spelling option for every person
 name_list_canonical="$(echo "$name_list" | cut -f 1,2 | uniq -f1)"
@@ -58,8 +99,24 @@ name_list_canonical="$(echo "$name_list" | cut -f 1,2 | uniq -f1)"
 cleaner_script="$(echo "$name_list_canonical" | denormalize_name | 
   sed -re 's/(.*)\t(.*)/s#^\2$#\1#g/g')"
 
+# Add github usernames
+if [ -n "$NIXPKGS_GITHUB_NAME_CACHE" ]; then
+    github_adder_script="$(echo "$github_name_list" |
+        grep -E "$(echo "$name_list_canonical" | cut -f 2 |
+	    tr '\n' '|' )" |
+	sort | uniq | 
+        sed -re 's/(.*)\t(.*)/s| \1$| \1\t\2|g;/' |
+	denormalize_name 
+	)"
+else
+    github_adder_script=''
+fi
+
 echo "$name_list" | denormalize_name
 
 echo
 
-echo "$git_data" | cut -f 1 | sed -re "$cleaner_script" | sort | uniq -c | sort -k1n
+echo "$git_data" | cut -f 1 |
+    sed -re "$cleaner_script" | 
+    sort | uniq -c | sort -k1n | sed -re "$github_adder_script" |
+    sed -re 's/^ *([0-9]+) /\1\t/'