Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
collaborators.php000064400000006073151157143710010136 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Collaborators class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/collaborators
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesCollaborators extends JGithubPackage
{
/**
* List.
*
* When authenticating as an organization owner of an organization-owned
repository, all organization
* owners are included in the list of collaborators. Otherwise, only users
with access to the repository
* are returned in the collaborators list.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Test if a user is a collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return boolean
*/
public function get($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204';
return true;
break;
case '404';
return false;
break;
default;
throw new UnexpectedValueException('Unexpected code: ' .
$response->code);
break;
}
}
/**
* Add collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function add($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
return $this->processResponse(
$this->client->put($this->fetchUrl($path), ''),
204
);
}
/**
* Remove collaborator.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $user The name of the GitHub user.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function remove($owner, $repo, $user)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
comments.php000064400000011512151157143710007107 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Comments class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/comments
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesComments extends JGithubPackage
{
/**
* Method to get a list of commit comments for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 3.0.0
*/
public function getListRepository($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Method to get a list of comments for a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 3.0.0
*/
public function getList($user, $repo, $sha, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path, $page, $limit))
);
}
/**
* Method to get a single comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the comment to retrieve
*
* @return array
*
* @since 3.0.0
*/
public function get($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to edit a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
* @param string $comment The text of the comment.
*
* @return object
*
* @since 3.0.0
*/
public function edit($user, $repo, $id, $comment)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
$data = json_encode(
array(
'body' => $comment,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to delete a comment on a commit.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $id The ID of the comment to edit.
*
* @return object
*
* @since 3.0.0
*/
public function delete($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to create a comment on a commit.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to comment on.
* @param string $comment The text of the comment.
* @param integer $line The line number of the commit to comment
on.
* @param string $filepath A relative path to the file to comment on
within the commit.
* @param integer $position Line index in the diff to comment on.
*
* @return object
*
* @since 3.0.0
*/
public function create($user, $repo, $sha, $comment, $line, $filepath,
$position)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';
$data = json_encode(
array(
'body' => $comment,
'path' => $filepath,
'position' => (int) $position,
'line' => (int) $line,
)
);
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
}
commits.php000064400000007474151157143710006751 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Commits class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/commits
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesCommits extends JGithubPackage
{
/**
* Method to list commits for a repository.
*
* A special note on pagination: Due to the way Git works, commits are
paginated based on SHA
* instead of page number.
* Please follow the link headers as outlined in the pagination overview
instead of constructing
* page links yourself.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha Sha or branch to start listing commits from.
* @param string $path Only commits containing this file path will
be returned.
* @param string $author GitHub login, name, or email by which to
filter by commit author.
* @param JDate $since ISO 8601 Date - Only commits after this date
will be returned.
* @param JDate $until ISO 8601 Date - Only commits before this date
will be returned.
*
* @throws DomainException
* @since 3.0.0
*
* @return array
*/
public function getList($user, $repo, $sha = '', $path =
'', $author = '', JDate $since = null, JDate $until =
null)
{
// Build the request path.
$rPath = '/repos/' . $user . '/' . $repo .
'/commits?';
$rPath .= ($sha) ? '&sha=' . $sha : '';
$rPath .= ($path) ? '&path=' . $path : '';
$rPath .= ($author) ? '&author=' . $author : '';
$rPath .= ($since) ? '&since=' . $since->toISO8601() :
'';
$rPath .= ($until) ? '&until=' . $until->toISO8601() :
'';
// Send the request.
$response = $this->client->get($this->fetchUrl($rPath));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a single commit for a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA of the commit to retrieve.
*
* @throws DomainException
* @since 3.0.0
*
* @return array
*/
public function get($user, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to get a diff for two commits.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $base The base of the diff, either a commit SHA or
branch.
* @param string $head The head of the diff, either a commit SHA or
branch.
*
* @return array
*
* @since 3.0.0
*/
public function compare($user, $repo, $base, $head)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/compare/' . $base . '...' . $head;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
}
contents.php000064400000012760151157143710007125 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Contents class for the Joomla Platform.
*
* These API methods let you retrieve the contents of files within a
repository as Base64 encoded content.
* See media types for requesting raw or other formats.
*
* @documentation https://developer.github.com/v3/repos/contents
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesContents extends JGithubPackage
{
/**
* Get the README
*
* This method returns the preferred README for a repository.
*
* GET /repos/:owner/:repo/readme
*
* Parameters
*
* ref
* Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
*
* Response
*
* Status: 200 OK
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* {
* "type": "file",
* "encoding": "base64",
* "_links": {
* "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
* "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
* "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
* },
* "size": 5362,
* "name": "README.md",
* "path": "README.md",
* "content": "encoded content ...",
* "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
* }
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The String name of the Commit/Branch/Tag.
Defaults to master.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getReadme($owner, $repo, $ref = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/readme';
if ($ref)
{
$path .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get contents
*
* This method returns the contents of any file or directory in a
repository.
*
* GET /repos/:owner/:repo/contents/:path
*
* Parameters
*
* path
* Optional string - The content path.
* ref
* Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
*
* Response
*
* Status: 200 OK
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* {
* "type": "file",
* "encoding": "base64",
* "_links": {
* "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
* "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
* "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
* },
* "size": 5362,
* "name": "README.md",
* "path": "README.md",
* "content": "encoded content ...",
* "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
* }
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $path The content path.
* @param string $ref The String name of the Commit/Branch/Tag.
Defaults to master.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $path, $ref = '')
{
// Build the request path.
$rPath = '/repos/' . $owner . '/' . $repo .
'/contents/' . $path;
if ($ref)
{
$rPath .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($rPath))
);
}
/**
* Get archive link
*
* This method will return a 302 to a URL to download a tarball or zipball
archive for a repository.
* Please make sure your HTTP framework is configured to follow redirects
or you will need to use the Location header to make a second GET request.
*
* Note: For private repositories, these links are temporary and expire
quickly.
*
* GET /repos/:owner/:repo/:archive_format/:ref
*
* Parameters
*
* archive_format
* Either tarball or zipball
* ref
* Optional string - valid Git reference, defaults to master
*
* Response
*
* Status: 302 Found
* Location:
http://github.com/me/myprivate/tarball/master?SSO=thistokenexpires
* X-RateLimit-Limit: 5000
* X-RateLimit-Remaining: 4999
*
* To follow redirects with curl, use the -L switch:
*
* curl -L https://api.github.com/repos/octokit/octokit.rb/tarball >
octokit.tar.gz
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $archiveFormat Either tarball or zipball.
* @param string $ref The String name of the
Commit/Branch/Tag. Defaults to master.
*
* @throws UnexpectedValueException
* @since 3.3 (CMS)
*
* @return object
*/
public function getArchiveLink($owner, $repo, $archiveFormat =
'zipball', $ref = '')
{
if (false == in_array($archiveFormat, array('tarball',
'zipball')))
{
throw new UnexpectedValueException('Archive format must be either
"tarball" or "zipball".');
}
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/' . $archiveFormat;
if ($ref)
{
$path .= '?ref=' . $ref;
}
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path)),
302
);
}
}
downloads.php000064400000014204151157143710007255 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Downloads class for the Joomla Platform.
*
* The downloads API is for package downloads only.
* If you want to get source tarballs you should use
* https://developer.github.com/v3/repos/contents/#get-archive-link
instead.
*
* @documentation https://developer.github.com/v3/repos/downloads
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesDownloads extends JGithubPackage
{
/**
* List downloads for a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads';
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a single download.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the download.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . $id;
// Send the request.
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a new download (Part 1: Create the resource).
*
* Creating a new download is a two step process. You must first create a
new download resource.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The name.
* @param string $size Size of file in bytes.
* @param string $description The description.
* @param string $contentType The content type.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $name, $size, $description =
'', $contentType = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads';
$data = array(
'name' => $name,
'size' => $size,
);
if ($description)
{
$data['description'] = $description;
}
if ($contentType)
{
$data['content_type'] = $contentType;
}
// Send the request.
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Create a new download (Part 2: Upload file to s3).
*
* Now that you have created the download resource, you can use the
information
* in the response to upload your file to s3. This can be done with a POST
to
* the s3_url you got in the create response. Here is a brief example
using curl:
*
* curl \
* -F "key=downloads/octocat/Hello-World/new_file.jpg" \
* -F "acl=public-read" \
* -F "success_action_status=201" \
* -F "Filename=new_file.jpg" \
* -F "AWSAccessKeyId=1ABCDEF..." \
* -F "Policy=ewogIC..." \
* -F "Signature=mwnF..." \
* -F "Content-Type=image/jpeg" \
* -F "file=@new_file.jpg" \
* https://github.s3.amazonaws.com/
*
* NOTES
* The order in which you pass these fields matters! Follow the order
shown above exactly.
* All parameters shown are required and if you excluded or modify them
your upload will
* fail because the values are hashed and signed by the policy.
*
* More information about using the REST API to interact with s3 can be
found here:
* http://docs.amazonwebservices.com/AmazonS3/latest/API/
*
* @param string $key Value of path field in the
response.
* @param string $acl Value of acl field in the
response.
* @param string $successActionStatus 201, or whatever you want to get
back.
* @param string $filename Value of name field in the
response.
* @param string $awsAccessKeyId Value of accesskeyid field in
the response.
* @param string $policy Value of policy field in the
response.
* @param string $signature Value of signature field in the
response.
* @param string $contentType Value of mime_type field in the
response.
* @param string $file Local file. Example assumes the
file existing in the directory
* where you are running the curl
command. Yes, the @ matters.
*
* @since 3.3 (CMS)
*
* @return boolean
*/
public function upload($key, $acl, $successActionStatus, $filename,
$awsAccessKeyId, $policy, $signature, $contentType, $file)
{
// Build the request path.
$url = 'https://github.s3.amazonaws.com/';
$data = array(
'key' => $key,
'acl' => $acl,
'success_action_status' => (int) $successActionStatus,
'Filename' => $filename,
'AWSAccessKeyId' => $awsAccessKeyId,
'Policy' => $policy,
'Signature' => $signature,
'Content-Type' => $contentType,
'file' => $file,
);
// Send the request.
$response = $this->client->post($url, $data);
// @todo Process the response..
return (201 == $response->code) ? true : false;
}
/**
* Delete a download.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the download.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function delete($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . (int) $id;
// Send the request.
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
forks.php000064400000004664151157143710006420 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Forks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/forks
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesForks extends JGithubPackage
{
/**
* Method to fork a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $org The organization to fork the repo into. By
default it is forked to the current user.
*
* @return object
*
* @since 2.5.0
* @throws DomainException
*/
public function create($user, $repo, $org = '')
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
if (strlen($org) > 0)
{
$data = json_encode(
array('org' => $org)
);
}
else
{
$data = json_encode(array());
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 202)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list forks for a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 2.5.0
* @throws DomainException
*/
public function getList($user, $repo, $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/forks';
// Send the request.
$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.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}
hooks.php000064400000014347151157143710006416 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Hooks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/hooks
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesHooks extends JGithubPackage
{
/**
* Array containing the allowed hook events
*
* @var array
* @since 3.1.4
*/
protected $events = array(
'push',
'issues',
'issue_comment',
'commit_comment',
'pull_request',
'gollum',
'watch',
'download',
'fork',
'fork_apply',
'member',
'public',
'status',
);
/**
* Method to create a hook on a repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the service.
* @param array $events The events the hook will be triggered for.
* @param boolean $active Flag to determine if the hook is active
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function create($user, $repo, $name, $config, array $events =
array('push'), $active = true)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
$data = json_encode(
array('name' => $name, 'config' => $config,
'events' => $events, 'active' => $active)
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path), $data),
201
);
}
/**
* Method to delete a hook
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete.
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function delete($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
/**
* Method to edit a hook.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to edit.
* @param string $name The name of the service being called.
* @param array $config Array containing the config for the
service.
* @param array $events The events the hook will be triggered
for. This resets the currently set list
* @param array $addEvents Events to add to the hook.
* @param array $removeEvents Events to remove from the hook.
* @param boolean $active Flag to determine if the hook is
active
*
* @return object
*
* @since 3.1.4
* @throws DomainException
* @throws RuntimeException
*/
public function edit($user, $repo, $id, $name, $config, array $events =
array('push'), array $addEvents = array(),
array $removeEvents = array(), $active = true)
{
// Check to ensure all events are in the allowed list
foreach ($events as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your events array contains an
unauthorized event.');
}
}
foreach ($addEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your active_events array contains an
unauthorized event.');
}
}
foreach ($removeEvents as $event)
{
if (!in_array($event, $this->events))
{
throw new RuntimeException('Your remove_events array contains an
unauthorized event.');
}
}
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
$data = json_encode(
array(
'name' => $name,
'config' => $config,
'events' => $events,
'add_events' => $addEvents,
'remove_events' => $removeEvents,
'active' => $active,
)
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
/**
* Method to get details about a single hook for the repository.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to retrieve
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function get($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to list hooks for a repository.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function getList($user, $repo)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to test a hook against the latest repository commit
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id ID of the hook to delete
*
* @return object
*
* @since 3.1.4
* @throws DomainException
*/
public function test($user, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id . '/test';
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode('')),
204
);
}
}
keys.php000064400000006367151157143710006251 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Forks class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/keys
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesKeys extends JGithubPackage
{
/**
* List keys in a repository.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
*
* @since 3.3.0
*
* @return object
*/
public function getList($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
*
* @since 3.3.0
*
* @return object
*/
public function get($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $title The key title.
* @param string $key The key.
*
* @since 3.3.0
*
* @return object
*/
public function create($owner, $repo, $title, $key)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys';
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
/**
* Edit a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
* @param string $title The key title.
* @param string $key The key.
*
* @since 3.3.0
*
* @return object
*/
public function edit($owner, $repo, $id, $title, $key)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
$data = array(
'title' => $title,
'key' => $key,
);
return $this->processResponse(
$this->client->patch($this->fetchUrl($path),
json_encode($data))
);
}
/**
* Delete a key.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param integer $id The id of the key.
*
* @since 3.3.0
*
* @return boolean
*/
public function delete($owner, $repo, $id)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;
$this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
return true;
}
}
merging.php000064400000004761151157143710006722 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API Repositories Merging class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/merging
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesMerging extends JGithubPackage
{
/**
* Perform a merge.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $base The name of the base branch that the
head will be merged into.
* @param string $head The head to merge. This can be a
branch name or a commit SHA1.
* @param string $commitMessage Commit message to use for the merge
commit.
* If omitted, a default message will be
used.
*
* @throws UnexpectedValueException
* @since 3.3.0
*
* @return boolean
*/
public function perform($owner, $repo, $base, $head, $commitMessage =
'')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/merges';
$data = new stdClass;
$data->base = $base;
$data->head = $head;
if ($commitMessage)
{
$data->commit_message = $commitMessage;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path),
json_encode($data));
switch ($response->code)
{
case '201':
// Success
return json_decode($response->body);
break;
case '204':
// No-op response (base already contains the head, nothing to merge)
throw new UnexpectedValueException('Nothing to merge');
break;
case '404':
// Missing base or Missing head response
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Missing base or head: ' . $response->code;
throw new UnexpectedValueException($message);
break;
case '409':
// Merge conflict response
$error = json_decode($response->body);
$message = (isset($error->message)) ? $error->message :
'Merge conflict ' . $response->code;
throw new UnexpectedValueException($message);
break;
default :
throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
break;
}
}
}
statistics.php000064400000011526151157143710007461 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API class for the Joomla Platform.
*
* The Repository Statistics API allows you to fetch the data that GitHub
uses for
* visualizing different types of repository activity.
*
* @documentation https://developer.github.com/v3/repos/statistics
*
* @since 3.3 (CMS)
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesStatistics extends JGithubPackage
{
/**
* Get contributors list with additions, deletions, and commit counts.
*
* Response include:
* total - The Total number of commits authored by the contributor.
*
* Weekly Hash
*
* w - Start of the week
* a - Number of additions
* d - Number of deletions
* c - Number of commits
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getListContributors($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/contributors';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the last year of commit activity data.
*
* Returns the last year of commit activity grouped by week.
* The days array is a group of commits per day, starting on Sunday.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getActivityData($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/commit_activity';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the number of additions and deletions per week.
*
* Response returns a weekly aggregate of the number of additions and
deletions pushed to a repository.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getCodeFrequency($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/code_frequency';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the weekly commit count for the repo owner and everyone else.
*
* Returns the total commit counts for the "owner" and total
commit counts in "all". "all" is everyone combined,
* including the owner in the last 52 weeks.
* If you’d like to get the commit counts for non-owners, you can
subtract all from owner.
*
* The array order is oldest week (index 0) to most recent week.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getParticipation($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/participation';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Get the number of commits per hour in each day.
*
* Response
* Each array contains the day number, hour number, and number of commits:
*
* 0-6: Sunday - Saturday
* 0-23: Hour of day
* Number of commits
*
* For example, [2, 14, 25] indicates that there were 25 total commits,
during the 2:00pm hour on Tuesdays.
* All times are based on the time zone of individual commits.
*
* @param string $owner The owner of the repository.
* @param string $repo The repository name.
*
* @since 1.0
*
* @return object
*/
public function getPunchCard($owner, $repo)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/stats/punch_card';
// Send the request.
return
$this->processResponse($this->client->get($this->fetchUrl($path)));
}
/**
* Process the response and decode it.
*
* @param JHttpResponse $response The response.
* @param integer $expectedCode The expected "good"
code.
* @param boolean $decode If the should be response be
JSON decoded.
*
* @return mixed
*
* @since 1.0
* @throws \DomainException
*/
protected function processResponse(JHttpResponse $response, $expectedCode
= 200, $decode = true)
{
if (202 == $response->code)
{
throw new \DomainException(
'GitHub is building the statistics data. Please try again in a few
moments.',
$response->code
);
}
return parent::processResponse($response, $expectedCode, $decode);
}
}
statuses.php000064400000005616151157143710007145 0ustar00<?php
/**
* @package Joomla.Platform
* @subpackage GitHub
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* GitHub API References class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/repos/statuses
*
* @since 3.1.4
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageRepositoriesStatuses extends JGithubPackage
{
/**
* Method to create a status.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value for which to set the
status.
* @param string $state The state (pending, success, error or
failure).
* @param string $targetUrl Optional target URL.
* @param string $description Optional description for the status.
*
* @throws InvalidArgumentException
* @throws DomainException
*
* @since 3.1.4
*
* @return object
*/
public function create($user, $repo, $sha, $state, $targetUrl = null,
$description = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
if (!in_array($state, array('pending', 'success',
'error', 'failure')))
{
throw new InvalidArgumentException('State must be one of pending,
success, error or failure.');
}
// Build the request data.
$data = array(
'state' => $state,
);
if (!is_null($targetUrl))
{
$data['target_url'] = $targetUrl;
}
if (!is_null($description))
{
$data['description'] = $description;
}
// Send the request.
$response = $this->client->post($this->fetchUrl($path),
json_encode($data));
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
/**
* Method to list statuses for an SHA.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha SHA1 for which to get the statuses.
*
* @return array
*
* @since 3.1.4
*/
public function getList($user, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
}