Skip to content

Instantly share code, notes, and snippets.

@neolit123
Last active July 17, 2018 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neolit123/f769f3c0c1d37f3e268cf71a1ffde1ab to your computer and use it in GitHub Desktop.
Save neolit123/f769f3c0c1d37f3e268cf71a1ffde1ab to your computer and use it in GitHub Desktop.
get-pr-emails.sh
#!/bin/sh
# a shell script for retrieving emails from commits in kubernetes/<repo> PRs
# example usage:
#
# $ chmod +x ./get-pr-emails.sh
# $ ./get-pr-emails.sh kubernetes <some-pr-#>
#
# getting username and branch...
# username = johndoe314314
# branch = some-feature-branch
# getting email addresses...
# "name": "John Doe",
# "email": "johndoe@thedoe.org",
#
# NOTES:
# - the script uses unauthorized GitHub API access and has a rate limit
# of 60 requests per hour.
# - the request can only work if the author's PR branch exists.
#
if [[ $# -eq 0 ]]; then
printf "usage: %s <repo> <pr#> \n" "$(basename "$0")" >&2
exit 1
fi
repo="$1"
pr="$2"
echo getting username and branch...
uname_branch=`curl https://github.com/kubernetes/$repo/pull/$pr -s | grep 'commit-ref css-truncate user-select-contain expandable head-ref'`
uname=`cut -d'>' -f3 <<< $uname_branch`
uname=`cut -d'<' -f1 <<< $uname`
branch=`cut -d'>' -f5 <<< $uname_branch`
branch=`cut -d'<' -f1 <<< $branch`
echo username = $uname
echo branch = $branch
echo getting email addresses...
curl https://api.github.com/repos/$uname/$repo/commits/$branch -s | grep -e '\"name\": \"' -e '\"email\": \"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment