2014-09-24 16:54:36 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
export LANG=C LC_ALL=C LC_COLLATE=C
|
|
|
|
|
|
|
|
# Load git log
|
2014-10-12 20:05:14 +01:00
|
|
|
raw_git_log="$(git log)"
|
2014-11-04 09:57:50 +00:00
|
|
|
git_data="$(echo "$raw_git_log" | grep 'Author:' |
|
|
|
|
sed -e 's/^ *Author://; s/\\//g; s/^ *//; s/ *$//;
|
2014-09-24 16:54:36 +01:00
|
|
|
s/ @ .*//; s/ *[<]/\t/; s/[>]//')"
|
|
|
|
|
|
|
|
# Name - nick - email correspondence from log and from maintainer list
|
|
|
|
# Also there are a few manual entries
|
2018-03-18 05:16:43 +00:00
|
|
|
maintainers="$(cat "$(dirname "$0")/../maintainer-list.nix" |
|
2014-09-24 16:54:36 +01:00
|
|
|
grep '=' | sed -re 's/\\"/''/g;
|
2015-12-08 18:11:43 +00:00
|
|
|
s/[ ]*([^ =]*)[ ]*=[ ]*" *(.*[^ ]) *[<](.*)[>] *".*/\1\t\2\t\3/')"
|
2014-11-04 09:57:50 +00:00
|
|
|
git_lines="$( ( echo "$git_data";
|
2014-10-07 13:25:33 +01:00
|
|
|
cat "$(dirname "$0")/vanity-manual-equalities.txt") | sort |uniq)"
|
2014-09-24 16:54:36 +01:00
|
|
|
|
2014-11-04 09:57:50 +00:00
|
|
|
emails="$(
|
|
|
|
( echo "$maintainers" | cut -f 3; echo "$git_data" | cut -f 2 ) |
|
|
|
|
sort | uniq | grep -E ".+@.+[.].+"
|
2014-10-12 20:05:14 +01:00
|
|
|
)"
|
|
|
|
|
|
|
|
fetchGithubName () {
|
|
|
|
commitid="$(
|
2014-11-04 09:57:50 +00:00
|
|
|
echo "$raw_git_log" | grep -B3 "Author: .*[<]$1[>]" | head -n 3 |
|
2014-10-12 20:05:14 +01:00
|
|
|
grep '^commit ' | tail -n 1 | sed -e 's/^commit //'
|
|
|
|
)"
|
|
|
|
userid="$(
|
|
|
|
curl https://github.com/NixOS/nixpkgs/commit/"$commitid" 2>/dev/null |
|
2016-02-24 09:37:34 +00:00
|
|
|
grep committed -B10 | grep 'href="/' |
|
2014-10-12 20:05:14 +01:00
|
|
|
sed -re 's@.* href="/@@; s@".*@@' |
|
2021-11-14 02:53:26 +00:00
|
|
|
grep -v "/commit/"
|
2014-10-12 20:05:14 +01:00
|
|
|
)";
|
|
|
|
echo "$userid"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -n "$NIXPKGS_GITHUB_NAME_CACHE" ] && {
|
2014-11-04 09:57:50 +00:00
|
|
|
echo "$emails" | while read email; do
|
2014-10-12 20:05:14 +01:00
|
|
|
line="$(grep "$email " "$NIXPKGS_GITHUB_NAME_CACHE")"
|
2021-11-14 02:53:26 +00:00
|
|
|
[ -z "$line" ] && {
|
2014-10-12 20:05:14 +01:00
|
|
|
echo "$email $(fetchGithubName "$email")" >> \
|
|
|
|
"$NIXPKGS_GITHUB_NAME_CACHE"
|
|
|
|
}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-09-24 16:54:36 +01:00
|
|
|
# For RDF
|
|
|
|
normalize_name () {
|
2021-11-14 02:53:26 +00:00
|
|
|
sed -e 's/%/%25/g; s/ /%20/g; s/'\''/%27/g; s/"/%22/g; s/`/%60/g; s/\^/%5e/g; '
|
2014-09-24 16:54:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
denormalize_name () {
|
2021-11-14 02:53:26 +00:00
|
|
|
sed -e 's/%20/ /g; s/%27/'\''/g; s/%22/"/g; s/%60/`/g; s/%5e/^/g; s/%25/%/g;';
|
2014-09-24 16:54:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
n3="$(mktemp --suffix .n3)"
|
|
|
|
|
|
|
|
# «The same person» relation and a sorting hint
|
|
|
|
# Full name is something with a space
|
|
|
|
(
|
|
|
|
echo "$git_lines" | sed -re 's@(.*)\t(.*)@<my://name/\1> <my://can-be> <my://name/\2>.@'
|
|
|
|
echo "$git_lines" | sed -re 's@(.*)\t(.*)@<my://name/\2> <my://can-be> <my://name/\1>.@'
|
|
|
|
echo "$maintainers" | sed -re 's@(.*)\t(.*)\t(.*)@<my://name/\1> <my://can-be> <my://name/\2>.@'
|
|
|
|
echo "$maintainers" | sed -re 's@(.*)\t(.*)\t(.*)@<my://name/\2> <my://can-be> <my://name/\3>.@'
|
|
|
|
echo "$maintainers" | sed -re 's@(.*)\t(.*)\t(.*)@<my://name/\3> <my://can-be> <my://name/\1>.@'
|
|
|
|
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>.@'
|
2014-10-12 20:05:14 +01:00
|
|
|
[ -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>.@'
|
2014-09-24 16:54:36 +01:00
|
|
|
) | normalize_name | grep -E '<my://[-a-z]+>' | sort | uniq > "$n3"
|
|
|
|
|
|
|
|
# Get transitive closure
|
2014-10-05 15:16:37 +01:00
|
|
|
sparql="$(nix-build '<nixpkgs>' -Q -A apache-jena --no-out-link)/bin/sparql"
|
2014-09-24 16:54:36 +01:00
|
|
|
name_list="$(
|
2021-11-14 02:53:26 +00:00
|
|
|
"$sparql" --results=TSV --data="$n3" "
|
2021-11-17 21:53:29 +00:00
|
|
|
select ?x ?y ?g where {
|
|
|
|
?x <my://can-be>+ ?y.
|
|
|
|
?x <my://is-name> ?g.
|
2014-09-24 16:54:36 +01:00
|
|
|
}
|
2021-11-17 21:53:29 +00:00
|
|
|
" | tail -n +2 |
|
2021-11-14 02:53:26 +00:00
|
|
|
sed -re 's@<my://name/@@g; s@<my://@@g; s@>@@g;' |
|
|
|
|
sort -k 2,3 -t ' '
|
2014-09-24 16:54:36 +01:00
|
|
|
)"
|
2014-10-12 20:05:14 +01:00
|
|
|
github_name_list="$(
|
2021-11-14 02:53:26 +00:00
|
|
|
"$sparql" --results=TSV --data="$n3" "
|
2021-11-17 21:53:29 +00:00
|
|
|
select ?x ?y where {
|
|
|
|
?x (<my://can-be>+ / <my://at-github>) ?y.
|
2014-10-12 20:05:14 +01:00
|
|
|
}
|
2021-11-17 21:53:29 +00:00
|
|
|
" | tail -n +2 |
|
2021-11-14 02:53:26 +00:00
|
|
|
sed -re 's@<my://(name|github)/@@g; s@<my://@@g; s@>@@g;'
|
2014-10-12 20:05:14 +01:00
|
|
|
)"
|
2014-09-24 16:54:36 +01:00
|
|
|
|
|
|
|
# Take first spelling option for every person
|
|
|
|
name_list_canonical="$(echo "$name_list" | cut -f 1,2 | uniq -f1)"
|
|
|
|
|
2014-11-04 09:57:50 +00:00
|
|
|
cleaner_script="$(echo "$name_list_canonical" | denormalize_name |
|
2014-09-24 16:54:36 +01:00
|
|
|
sed -re 's/(.*)\t(.*)/s#^\2$#\1#g/g')"
|
|
|
|
|
2014-10-12 20:05:14 +01:00
|
|
|
# Add github usernames
|
|
|
|
if [ -n "$NIXPKGS_GITHUB_NAME_CACHE" ]; then
|
2016-09-26 18:24:05 +01:00
|
|
|
github_adder_script="$(mktemp)"
|
|
|
|
echo "$github_name_list" |
|
2014-10-12 20:05:14 +01:00
|
|
|
grep -E "$(echo "$name_list_canonical" | cut -f 2 |
|
2021-11-14 02:53:26 +00:00
|
|
|
tr '\n' '|' )" |
|
|
|
|
sort | uniq |
|
2014-10-12 20:05:14 +01:00
|
|
|
sed -re 's/(.*)\t(.*)/s| \1$| \1\t\2|g;/' |
|
2021-11-14 02:53:26 +00:00
|
|
|
denormalize_name > "$github_adder_script"
|
2014-10-12 20:05:14 +01:00
|
|
|
else
|
2016-09-26 18:24:05 +01:00
|
|
|
github_adder_script='/dev/null'
|
2014-10-12 20:05:14 +01:00
|
|
|
fi
|
|
|
|
|
2014-09-24 16:54:36 +01:00
|
|
|
echo "$name_list" | denormalize_name
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2014-10-12 20:05:14 +01:00
|
|
|
echo "$git_data" | cut -f 1 |
|
2014-11-04 09:57:50 +00:00
|
|
|
sed -e "$cleaner_script" |
|
2016-09-26 18:24:05 +01:00
|
|
|
sort | uniq -c | sort -k1n | sed -rf "$github_adder_script" |
|
2014-10-12 20:05:14 +01:00
|
|
|
sed -re 's/^ *([0-9]+) /\1\t/'
|