-
Notifications
You must be signed in to change notification settings - Fork 88
/
get_contributors.sh
executable file
·88 lines (74 loc) · 2.49 KB
/
get_contributors.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# Get a list of all contributors that contributed in some way
# either by directly opening a PR, or by participating in issues.
#
# This script is a helper to fill out the "Contributors" chapter.
# It'll only spit out the names and an user must add them to the book.
#
# This script takes two arguments:
# - `username`: Your github username used to authenticate the GitHub API
# - `token`: A github Personal Access Token used to authenticate the GitHub API
set -euo pipefail
# Check if there are `username` and `token` arguments
if [ $# -eq 0 ]
then
user="$(git config github.user)"
token="$(git config github.oauth-token)"
elif [ $# -eq 2 ]
then
user="$1"
token="$2"
else
user=""
token=""
fi
if [ "$user" == "" -o "$token" == "" ]
then
echo "github token required. The token is normally loaded from"
echo "git config (github.user, github.oauth-token), but you can"
echo "also use as follows:"
echo ""
echo "Usage: $0 <username> <token>"
exit 1
fi
# Check if a command is available, otherwise exit.
function check_bin() {
if ! command -v $1 &> /dev/null
then
echo "'$1' is not installed, but required to run this script."
exit 1
fi
}
check_bin curl
check_bin jq
function get_issue_numbers() {
local result="$(curl -s -u $user:$token -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/rust-lang/wg-async/issues?state=all&labels=$1&per_page=100" \
| jq '.[].number')"
if [ "$(echo $result | wc -w)" -ge 100 ];
then
echo "Found 100 results for $1. Due to GitHub's paging limits, there might be some issues that are missing"
fi
echo $result
}
# Get a list of users that participated in issues.
function issue_contributors() {
local numbers="$(get_issue_numbers status-quo-story-ideas) $(get_issue_numbers shiny-future)"
local numbers="$(echo $numbers | sort | uniq)"
for num in $numbers; do
curl -s -u $user:$token -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/rust-lang/wg-async/issues/$num/comments | jq -r \
'.[] | "[" + .user.login + "](" + .user.html_url + ")"'
done | sort | uniq
}
# Get a list of direct code contributors
function code_contributors() {
curl -s -u $user:$token -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/rust-lang/wg-async/contributors?per_page=100" | jq -r \
'.[] | "[" + .login + "](" + .html_url + ")"' | sort | uniq
}
echo "Issue contributors"
issue_contributors
echo
echo "Code contributors"
code_contributors