diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-06-13 13:05:33 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-06-13 16:17:17 +0200 |
commit | e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc (patch) | |
tree | 7c64ef47688876f85dfb4333c1d91d6be3fbe4a2 /git-tools/merge.php | |
parent | bcc98ae3e7dce9c1c967622d2fccebbb0f07e9fe (diff) | |
download | forums-e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc.tar forums-e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc.tar.gz forums-e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc.tar.bz2 forums-e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc.tar.xz forums-e4ccc5e6eac2bfebb8770a1a8f73f965ef0146fc.zip |
[ticket/11603] Fix github API calls
- Some URLs changed
- Response is a plain array now
- Added error messages when API limit is reached
PHPBB3-11603
Diffstat (limited to 'git-tools/merge.php')
-rwxr-xr-x | git-tools/merge.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/git-tools/merge.php b/git-tools/merge.php index 2acd2280b9..5eb48a53f8 100755 --- a/git-tools/merge.php +++ b/git-tools/merge.php @@ -128,6 +128,7 @@ function api_request($query) curl_setopt($c, CURLOPT_URL, "https://api.github.com/$query"); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0'); + curl_setopt($c, CURLOPT_HEADER, true); $contents = curl_exec($c); curl_close($c); @@ -135,13 +136,19 @@ function api_request($query) { throw new RuntimeException("Error: failed to retrieve pull request data\n", 4); } + $contents = json_decode($contents); - return json_decode($contents); + if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0) + { + exit('Reached github API Rate Limit. Please try again later' . "\n"); + } + + return $contents; } function get_pull($username, $repository, $pull_id) { - $request = api_request("pulls/$username/$repository/$pull_id"); + $request = api_request("repos/$username/$repository/pulls/$pull_id"); $pull = $request->pull; |