diff options
Diffstat (limited to 'git-tools/merge.php')
-rwxr-xr-x | git-tools/merge.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/git-tools/merge.php b/git-tools/merge.php index 41a96c0890..f6142095fb 100755 --- a/git-tools/merge.php +++ b/git-tools/merge.php @@ -124,19 +124,34 @@ function get_repository_url($username, $repository, $ssh = false) function api_request($query) { - $contents = file_get_contents("http://github.com/api/v2/json/$query"); + return api_url_request("https://api.github.com/$query?per_page=100"); +} + +function api_url_request($url) +{ + $contents = file_get_contents($url, false, stream_context_create(array( + 'http' => array( + 'header' => "User-Agent: phpBB/1.0\r\n", + ), + ))); if ($contents === false) { throw new RuntimeException("Error: failed to retrieve pull request data\n", 4); } + $contents = json_decode($contents); + + if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0) + { + throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4); + } - return json_decode($contents); + 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; |