Skip to content

Commit 54fe688

Browse files
committed
BUG: Fail gracefully in git-pr with too many requests
The response can be: {'message': "API rate limit exceeded for 97.65.134.139. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", 'documentation_url': 'https://developer.github.com/v3/#rate-limiting'}
1 parent 15a0875 commit 54fe688

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Utilities/GitSetup/git-pr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ if [[ $# -lt 1 ]]; then
3232
repo_name=$(git config -f "$config" --get github.repo-name)
3333
url="https://api.$host/repos/$organization_name/$repo_name/pulls?sort=updated;direction=desc"
3434
pr_prompt=$(curl -s "https://api.$host/repos/$organization_name/$repo_name/pulls?sort=updated;direction=desc" \
35-
| $python_exe -c "import sys, json; res = json.load(sys.stdin); [print(str(pr['number']) + ': ' + pr['title']) for pr in res];")
35+
| $python_exe -c "import sys, json; res = json.load(sys.stdin); [print(str(pr['number']) + ': ' + str(pr['title'])) for pr in res] if 'pr' in res else sys.exit(1);")
36+
if [ $? -ne 0 ]; then
37+
usage
38+
exit 1
39+
fi
3640
echo "$pr_prompt"
3741
echo ""
3842
pr_number=$(echo "$pr_prompt" | sed -n -e "s/\([[:alnum:]]\+\).*/\1/p" | tail -n1)

0 commit comments

Comments
 (0)