Spade
Mini Shell
blobs.php000064400000003465151173131300006361 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 Data Blobs class for the Joomla Platform.
*
* Since blobs can be any arbitrary binary data, the input and responses
for the blob API
* takes an encoding parameter that can be either utf-8 or base64. If your
data cannot be
* losslessly sent as a UTF-8 string, you can base64 encode it.
*
* @documentation https://developer.github.com/v3/git/blobs/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataBlobs extends JGithubPackage
{
/**
* Get a Blob.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $sha The commit SHA.
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Blob.
*
* @param string $owner Repository owner.
* @param string $repo Repository name.
* @param string $content The content of the blob.
* @param string $encoding The encoding to use.
*
* @return object
*/
public function create($owner, $repo, $content, $encoding =
'utf-8')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs';
$data = array(
'content' => $content,
'encoding' => $encoding,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}
commits.php000064400000004276151173131300006734 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 Data Commits class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/git/commits/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataCommits extends JGithubPackage
{
/**
* Get a single commit.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The commit SHA.
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/commits/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Method to create a commit.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $message The commit message.
* @param string $tree SHA of the tree object this commit points
to.
* @param array $parents Array of the SHAs of the commits that were
the parents of this commit.
* If omitted or empty, the commit will be
written as a root commit.
* For a single parent, an array of one SHA
should be provided.
* For a merge commit, an array of more than
one should be provided.
*
* @throws DomainException
* @since 3.0.0
*
* @return object
*/
public function create($owner, $repo, $message, $tree, array $parents =
array())
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/commits';
$data = json_encode(
array('message' => $message, 'tree' => $tree,
'parents' => $parents)
);
// Send the request.
return $this->processResponse(
$response = $this->client->post($this->fetchUrl($path), $data),
201
);
}
}
refs.php000064400000012016151173131300006207 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/git/refs/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataRefs extends JGithubPackage
{
/**
* Method to get a reference.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to get.
*
* @return object
*
* @since 1.7.3
*/
public function get($user, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// 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 list references 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 $namespace Optional sub-namespace to limit the
returned references.
* @param integer $page Page to request
* @param integer $limit Number of results to return per page
*
* @return array
*
* @since 1.7.3
*/
public function getList($user, $repo, $namespace = '', $page =
0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs' . $namespace;
// 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);
}
/**
* Method to create a ref.
*
* @param string $user The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The name of the fully qualified reference.
* @param string $sha The SHA1 value to set this reference to.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function create($user, $repo, $ref, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs';
// Build the request data.
$data = json_encode(
array(
'ref' => $ref,
'sha' => $sha,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $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 update a reference.
*
* @param string $user The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $ref The reference to update.
* @param string $sha The SHA1 value to set the reference to.
* @param boolean $force Whether the update should be forced. Default
to false.
*
* @throws DomainException
* @since 1.7.3
*
* @return object
*/
public function edit($user, $repo, $ref, $sha, $force = false)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;
// Craete the data object.
$data = new stdClass;
// If a title is set add it to the data object.
if ($force)
{
$data->force = true;
}
$data->sha = $sha;
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// 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);
}
/**
* Delete a Reference
*
* @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 reference to update.
*
* @since 3.3 (CMS)
* @return object
*/
public function delete($owner, $repo, $ref)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/refs/' . $ref;
return $this->processResponse(
$this->client->delete($this->fetchUrl($path)),
204
);
}
}
tags.php000064400000005533151173131300006214 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 Data Tags class for the Joomla Platform.
*
* This tags API only deals with tag objects - so only annotated tags, not
lightweight tags.
*
* @documentation https://developer.github.com/v3/git/tags/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataTags extends JGithubPackage
{
/**
* Get a Tag.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/tags/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Tag Object
*
* Note that creating a tag object does not create the reference that
makes a tag in Git.
* If you want to create an annotated tag in Git, you have to do this call
to create the tag object,
* and then create the refs/tags/[tag] reference. If you want to create a
lightweight tag,
* you simply have to create the reference - this call would be
unnecessary.
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $tag The tag string.
* @param string $message The tag message.
* @param string $object The SHA of the git object this is
tagging.
* @param string $type The type of the object we’re tagging.
Normally this is a commit
* but it can also be a tree or a blob.
* @param string $taggerName The name of the author of the tag.
* @param string $taggerEmail The email of the author of the tag.
* @param string $taggerDate Timestamp of when this object was
tagged.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $tag, $message, $object, $type,
$taggerName, $taggerEmail, $taggerDate)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/tags';
$data = array(
'tag' => $tag,
'message' => $message,
'object' => $object,
'type' => $type,
'tagger_name' => $taggerName,
'tagger_email' => $taggerEmail,
'tagger_date' => $taggerDate,
);
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}
trees.php000064400000006431151173131300006376 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 Data Trees class for the Joomla Platform.
*
* @documentation https://developer.github.com/v3/git/trees/
*
* @since 1.7.3
* @deprecated 4.0 Use the `joomla/github` package via Composer instead
*/
class JGithubPackageDataTrees extends JGithubPackage
{
/**
* Get a Tree
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function get($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha;
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Get a Tree Recursively
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param string $sha The SHA1 value to set the reference to.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function getRecursively($owner, $repo, $sha)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha . '?recursive=1';
return $this->processResponse(
$this->client->get($this->fetchUrl($path))
);
}
/**
* Create a Tree.
*
* The tree creation API will take nested entries as well. If both a tree
and a nested path
* modifying that tree are specified, it will overwrite the contents of
that tree with the
* new path contents and write a new tree out.
*
* Parameters fir the tree:
*
* tree.path
* String of the file referenced in the tree
* tree.mode
* String of the file mode - one of 100644 for file (blob), 100755 for
executable (blob),
* 040000 for subdirectory (tree), 160000 for submodule (commit) or
120000 for a blob
* that specifies the path of a symlink
* tree.type
* String of blob, tree, commit
* tree.sha
* String of SHA1 checksum ID of the object in the tree
* tree.content
* String of content you want this file to have - GitHub will write
this blob out and use
* that SHA for this entry. Use either this or tree.sha
*
* @param string $owner The name of the owner of the GitHub
repository.
* @param string $repo The name of the GitHub repository.
* @param array $tree Array of Hash objects (of path, mode, type
and sha) specifying
* a tree structure
* @param string $baseTree The SHA1 of the tree you want to update
with new data.
*
* @since 3.3 (CMS)
*
* @return object
*/
public function create($owner, $repo, $tree, $baseTree = '')
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo .
'/git/trees';
$data = array();
$data['tree'] = $tree;
if ($baseTree)
{
$data['base_tree'] = $baseTree;
}
return $this->processResponse(
$this->client->post($this->fetchUrl($path),
json_encode($data)),
201
);
}
}