Source for file pulls.php
Documentation is available at pulls.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* GitHub API Pull Requests class for the Joomla Platform.
* @package Joomla.Platform
* Method to create a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $title The title of the new pull request.
* @param string $base The branch (or git ref) you want your changes pulled into. This
* should be an existing branch on the current repository. You cannot
* submit a pull request to one repo that requests a merge to a base
* @param string $head The branch (or git ref) where your changes are implemented.
* @param string $body The body text for the new pull request.
public function create($user, $repo, $title, $base, $head, $body =
'')
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls';
// Build the request data.
// Validate the response code.
if ($response->code !=
201)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to create a comment on a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param string $commitId The SHA1 hash of the commit to comment on.
* @param string $filePath The Relative path of the file to comment on.
* @param string $position The line index in the diff to comment on.
public function createComment($user, $repo, $pullId, $body, $commitId, $filePath, $position)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/comments';
// Build the request data.
'commit_id' =>
$commitId,
// Validate the response code.
if ($response->code !=
201)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to create a comment in reply to another comment.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $body The comment body text.
* @param integer $inReplyTo The id of the comment to reply to.
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/comments';
// Build the request data.
'in_reply_to' => (int)
$inReplyTo
// Validate the response code.
if ($response->code !=
201)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to create a pull request from an existing issue.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number for which to attach the new pull request.
* @param string $base The branch (or git ref) you want your changes pulled into. This
* should be an existing branch on the current repository. You cannot
* submit a pull request to one repo that requests a merge to a base
* @param string $head The branch (or git ref) where your changes are implemented.
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls';
// Build the request data.
'issue' => (int)
$issueId,
// Validate the response code.
if ($response->code !=
201)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to delete a comment on a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to delete.
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/comments/' . (int)
$commentId;
// Validate the response code.
if ($response->code !=
204)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to update a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $title The optional new title for the pull request.
* @param string $body The optional new body text for the pull request.
* @param string $state The optional new state for the pull request. [open, closed]
public function edit($user, $repo, $pullId, $title =
null, $body =
null, $state =
null)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId;
// Craete the data object.
// If a title is set add it to the data object.
// If a body is set add it to the data object.
// If a state is set add it to the data object.
// Encode the request data.
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to update a comment on a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The id of the comment to update.
* @param string $body The new body text for the comment.
public function editComment($user, $repo, $commentId, $body)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/comments/' . (int)
$commentId;
// Build the request data.
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to get a single pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
public function get($user, $repo, $pullId)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId;
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to get a specific comment on a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $commentId The comment id to get.
public function getComment($user, $repo, $commentId)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/comments/' . (int)
$commentId;
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to get the list of comments on a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
public function getComments($user, $repo, $pullId, $page =
0, $limit =
0)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/comments';
$response =
$this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to get a list of commits for a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
public function getCommits($user, $repo, $pullId, $page =
0, $limit =
0)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/commits';
$response =
$this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to get a list of files for a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
public function getFiles($user, $repo, $pullId, $page =
0, $limit =
0)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/files';
$response =
$this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to list pull requests.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $state The optional state to filter requests by. [open, closed]
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
public function getList($user, $repo, $state =
'open', $page =
0, $limit =
0)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls';
// If a state exists append it as an option.
$path .=
'?state=' .
$state;
$response =
$this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to check if a pull request has been merged.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number. The pull request number.
* @return boolean True if the pull request has been merged.
public function isMerged($user, $repo, $pullId)
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/merge';
// Validate the response code.
if ($response->code ==
204)
elseif ($response->code ==
404)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
* Method to merge a pull request.
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number.
* @param string $message The message that will be used for the merge commit.
public function merge($user, $repo, $pullId, $message =
'')
// Build the request path.
$path =
'/repos/' .
$user .
'/' .
$repo .
'/pulls/' . (int)
$pullId .
'/merge';
// Build the request data.
'commit_message' =>
$message
// Validate the response code.
if ($response->code !=
200)
// Decode the error response and throw an exception.
throw
new DomainException($error->message, $response->code);
Documentation generated on Tue, 19 Nov 2013 15:11:24 +0100 by phpDocumentor 1.4.3