Release of v5.0.0-alpha8
Add power path override option on component level. Fix the sql build feature. #1032.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Archive
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Archive extends Api
|
||||
{
|
||||
/**
|
||||
* Get an archive of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $archive The archive format, e.g., "zip" or "tar.gz".
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $archive
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/archive/{$archive}";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('archive', $archive);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Assignees
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Assignees extends Api
|
||||
{
|
||||
/**
|
||||
* Return all users that have write access and can be assigned to issues.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/assignees";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Attachments
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Attachments extends Api
|
||||
{
|
||||
/**
|
||||
* List release's attachments.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets";
|
||||
|
||||
// Retrieve the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a release attachment.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
* @param string $attachmentFile The attachment file content.
|
||||
* @param string $attachmentName The attachment file name.
|
||||
* @param string $contentType The attachment content type.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId,
|
||||
string $attachmentFile,
|
||||
string $attachmentName,
|
||||
string $contentType
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets";
|
||||
|
||||
// Retrieve the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the attachment name as a query parameter.
|
||||
$uri->setVar('name', $attachmentName);
|
||||
|
||||
// Set the request headers.
|
||||
$headers = [
|
||||
"Content-Type: {$contentType}",
|
||||
"Content-Disposition: attachment; filename={$attachmentName}"
|
||||
];
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$uri, $attachmentFile, $headers
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
* @param string|null $name The new name of the attachment (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId,
|
||||
?string $name = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Set the attachment data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($name !== null)
|
||||
{
|
||||
$data->name = $name;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
148
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Branch.php
Normal file
148
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Branch.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Branch
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Branch extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's branches.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch_name The name of the new branch.
|
||||
* @param string $old_branch The name of the existing branch from which to create the new branch.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branch_name,
|
||||
string $old_branch
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches";
|
||||
|
||||
// Set the branch data.
|
||||
$data = new \stdClass();
|
||||
$data->branch_name = $branch_name;
|
||||
$data->old_branch = $old_branch;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific branch from a repository, including its effective branch protection.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch The branch name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $branch): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches/{$branch}";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('branch', $branch);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific branch from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch The branch name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branch
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches/{$branch}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository\Branch;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Branch Protection
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Protection extends Api
|
||||
{
|
||||
/**
|
||||
* List branch protections for a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repositoryName The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $ownerName, string $repositoryName): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repositoryName}/branch_protections";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch protection for a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branchName The name of the branch to protect.
|
||||
* @param array $approvalsWhitelistUsernames An array of usernames that can approve.
|
||||
* @param array $approvalsWhitelistTeams An array of team names that can approve.
|
||||
* @param bool $blockOnOfficialReviewRequests Enable/disable blocking on official review requests (optional, default false).
|
||||
* @param bool $blockOnOutdatedBranch Enable/disable blocking on outdated branch (optional, default false).
|
||||
* @param bool $blockOnRejectedReviews Enable/disable blocking on rejected reviews (optional, default false).
|
||||
* @param bool $dismissStaleApprovals Enable/disable dismissing stale approvals (optional, default false).
|
||||
* @param bool $enableApprovalsWhitelist Enable/disable approvals whitelist (optional, default false).
|
||||
* @param bool $enableMergeWhitelist Enable/disable merge whitelist (optional, default false).
|
||||
* @param bool $enablePush Enable/disable push (optional, default true).
|
||||
* @param bool $enablePushWhitelist Enable/disable push whitelist (optional, default false).
|
||||
* @param bool $enableStatusCheck Enable/disable status check (optional, default false).
|
||||
* @param array $mergeWhitelistUsernames An array of usernames that can merge (optional).
|
||||
* @param array $mergeWhitelistTeams An array of team names that can merge (optional).
|
||||
* @param string $protectedFilePatterns Protected file patterns (optional).
|
||||
* @param bool $pushWhitelistDeployKeys Enable/disable push whitelist deploy keys (optional, default false).
|
||||
* @param array $pushWhitelistUsernames An array of usernames that can push (optional).
|
||||
* @param array $pushWhitelistTeams An array of team names that can push (optional).
|
||||
* @param bool $requireSignedCommits Enable/disable requiring signed commits (optional, default false).
|
||||
* @param int $requiredApprovals Number of required approvals (optional, default 0).
|
||||
* @param array $statusCheckContexts An array of status check contexts (optional).
|
||||
* @param string $unprotectedFilePatterns Unprotected file patterns (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branchName,
|
||||
array $approvalsWhitelistUsernames,
|
||||
array $approvalsWhitelistTeams,
|
||||
bool $blockOnOfficialReviewRequests = false,
|
||||
bool $blockOnOutdatedBranch = false,
|
||||
bool $blockOnRejectedReviews = false,
|
||||
bool $dismissStaleApprovals = false,
|
||||
bool $enableApprovalsWhitelist = false,
|
||||
bool $enableMergeWhitelist = false,
|
||||
bool $enablePush = true,
|
||||
bool $enablePushWhitelist = false,
|
||||
bool $enableStatusCheck = false,
|
||||
array $mergeWhitelistUsernames = [],
|
||||
array $mergeWhitelistTeams = [],
|
||||
string $protectedFilePatterns = '',
|
||||
bool $pushWhitelistDeployKeys = false,
|
||||
array $pushWhitelistUsernames = [],
|
||||
array $pushWhitelistTeams = [],
|
||||
bool $requireSignedCommits = false,
|
||||
int $requiredApprovals = 0,
|
||||
array $statusCheckContexts = [],
|
||||
string $unprotectedFilePatterns = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections";
|
||||
|
||||
// Set the branch protection data.
|
||||
$data = new \stdClass();
|
||||
$data->branch_name = $branchName;
|
||||
$data->approvals_whitelist_usernames = $approvalsWhitelistUsernames;
|
||||
$data->approvals_whitelist_teams = $approvalsWhitelistTeams;
|
||||
$data->block_on_official_review_requests = $blockOnOfficialReviewRequests;
|
||||
$data->block_on_outdated_branch = $blockOnOutdatedBranch;
|
||||
$data->block_on_rejected_reviews = $blockOnRejectedReviews;
|
||||
$data->dismiss_stale_approvals = $dismissStaleApprovals;
|
||||
$data->enable_approvals_whitelist = $enableApprovalsWhitelist;
|
||||
$data->enable_merge_whitelist = $enableMergeWhitelist;
|
||||
$data->enable_push = $enablePush;
|
||||
$data->enable_push_whitelist = $enablePushWhitelist;
|
||||
$data->enable_status_check = $enableStatusCheck;
|
||||
$data->merge_whitelist_usernames = $mergeWhitelistUsernames;
|
||||
$data->merge_whitelist_teams = $mergeWhitelistTeams;
|
||||
$data->protected_file_patterns = $protectedFilePatterns;
|
||||
$data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys;
|
||||
$data->push_whitelist_usernames = $pushWhitelistUsernames;
|
||||
$data->push_whitelist_teams = $pushWhitelistTeams;
|
||||
$data->require_signed_commits = $requireSignedCommits;
|
||||
$data->required_approvals = $requiredApprovals;
|
||||
$data->status_check_contexts = $statusCheckContexts;
|
||||
$data->unprotected_file_patterns = $unprotectedFilePatterns;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific branch protection for the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branchName The branch protection name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branchName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections/{$branchName}";
|
||||
|
||||
// Get the URI object with the given path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific branch protection for the repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $branchName The branch protection name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $branchName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/branch_protections/{$branchName}";
|
||||
|
||||
// Set the required variables in the URI.
|
||||
$this->uri->setVar('owner', $ownerName);
|
||||
$this->uri->setVar('repo', $repoName);
|
||||
$this->uri->setVar('name', $branchName);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a branch protection for a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The branch protection name.
|
||||
* @param array|null $approvalsWhitelistTeams An array of team names that are allowed to approve (optional).
|
||||
* @param array|null $approvalsWhitelistUsernames An array of usernames that are allowed to approve (optional).
|
||||
* @param bool|null $blockOnOfficialReviewRequests Block when official review requests are pending (optional).
|
||||
* @param bool|null $blockOnOutdatedBranch Block when the branch is outdated (optional).
|
||||
* @param bool|null $blockOnRejectedReviews Block when reviews are rejected (optional).
|
||||
* @param bool|null $dismissStaleApprovals Dismiss stale approvals when new commits are pushed (optional).
|
||||
* @param bool|null $enableApprovalsWhitelist Enable/disable approvals whitelist (optional).
|
||||
* @param bool|null $enableMergeWhitelist Enable/disable merge whitelist (optional).
|
||||
* @param bool|null $enablePush Enable/disable push (optional).
|
||||
* @param bool|null $enablePushWhitelist Enable/disable push whitelist (optional).
|
||||
* @param bool|null $enableStatusCheck Enable/disable status check (optional).
|
||||
* @param array|null $mergeWhitelistTeams An array of team names that are allowed to merge (optional).
|
||||
* @param array|null $mergeWhitelistUsernames An array of usernames that are allowed to merge (optional).
|
||||
* @param string|null $protectedFilePatterns A string pattern for protected files (optional).
|
||||
* @param bool|null $pushWhitelistDeployKeys Enable/disable push whitelist for deploy keys (optional).
|
||||
* @param array|null $pushWhitelistTeams An array of team names that are allowed to push (optional).
|
||||
* @param array|null $pushWhitelistUsernames An array of usernames that are allowed to push (optional).
|
||||
* @param bool|null $requireSignedCommits Require signed commits (optional).
|
||||
* @param int|null $requiredApprovals Number of required approvals (optional).
|
||||
* @param array|null $statusCheckContexts An array of status check contexts (optional).
|
||||
* @param string|null $unprotectedFilePatterns A string pattern for unprotected files (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name,
|
||||
?array $approvalsWhitelistTeams = null,
|
||||
?array $approvalsWhitelistUsernames = null,
|
||||
?bool $blockOnOfficialReviewRequests = null,
|
||||
?bool $blockOnOutdatedBranch = null,
|
||||
?bool $blockOnRejectedReviews = null,
|
||||
?bool $dismissStaleApprovals = null,
|
||||
?bool $enableApprovalsWhitelist = null,
|
||||
?bool $enableMergeWhitelist = null,
|
||||
?bool $enablePush = null,
|
||||
?bool $enablePushWhitelist = null,
|
||||
?bool $enableStatusCheck = null,
|
||||
?array $mergeWhitelistTeams = null,
|
||||
?array $mergeWhitelistUsernames = null,
|
||||
?string $protectedFilePatterns = null,
|
||||
?bool $pushWhitelistDeployKeys = null,
|
||||
?array $pushWhitelistTeams = null,
|
||||
?array $pushWhitelistUsernames = null,
|
||||
?bool $requireSignedCommits = null,
|
||||
?int $requiredApprovals = null,
|
||||
?array $statusCheckContexts = null,
|
||||
?string $unprotectedFilePatterns = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections/{$name}";
|
||||
|
||||
// Set the branch protection data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($approvalsWhitelistTeams !== null)
|
||||
{
|
||||
$data->approvals_whitelist_teams = $approvalsWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($approvalsWhitelistUsernames !== null)
|
||||
{
|
||||
$data->approvals_whitelist_usernames = $approvalsWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($blockOnOfficialReviewRequests !== null)
|
||||
{
|
||||
$data->block_on_official_review_requests = $blockOnOfficialReviewRequests;
|
||||
}
|
||||
|
||||
if ($blockOnOutdatedBranch !== null)
|
||||
{
|
||||
$data->block_on_outdated_branch = $blockOnOutdatedBranch;
|
||||
}
|
||||
|
||||
if ($blockOnRejectedReviews !== null)
|
||||
{
|
||||
$data->block_on_rejected_reviews = $blockOnRejectedReviews;
|
||||
}
|
||||
|
||||
if ($dismissStaleApprovals !== null)
|
||||
{
|
||||
$data->dismiss_stale_approvals = $dismissStaleApprovals;
|
||||
}
|
||||
|
||||
if ($enableApprovalsWhitelist !== null)
|
||||
{
|
||||
$data->enable_approvals_whitelist = $enableApprovalsWhitelist;
|
||||
}
|
||||
|
||||
if ($enableMergeWhitelist !== null)
|
||||
{
|
||||
$data->enable_merge_whitelist = $enableMergeWhitelist;
|
||||
}
|
||||
|
||||
if ($enablePush !== null)
|
||||
{
|
||||
$data->enable_push = $enablePush;
|
||||
}
|
||||
|
||||
if ($enablePushWhitelist !== null)
|
||||
{
|
||||
$data->enable_push_whitelist = $enablePushWhitelist;
|
||||
}
|
||||
|
||||
if ($enableStatusCheck !== null)
|
||||
{
|
||||
$data->enable_status_check = $enableStatusCheck;
|
||||
}
|
||||
|
||||
if ($mergeWhitelistTeams !== null)
|
||||
{
|
||||
$data->merge_whitelist_teams = $mergeWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($mergeWhitelistUsernames !== null)
|
||||
{
|
||||
$data->merge_whitelist_usernames = $mergeWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($protectedFilePatterns !== null)
|
||||
{
|
||||
$data->protected_file_patterns = $protectedFilePatterns;
|
||||
}
|
||||
|
||||
if ($pushWhitelistDeployKeys !== null)
|
||||
{
|
||||
$data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys;
|
||||
}
|
||||
|
||||
if ($pushWhitelistTeams !== null)
|
||||
{
|
||||
$data->push_whitelist_teams = $pushWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($pushWhitelistUsernames !== null)
|
||||
{
|
||||
$data->push_whitelist_usernames = $pushWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($requireSignedCommits !== null)
|
||||
{
|
||||
$data->require_signed_commits = $requireSignedCommits;
|
||||
}
|
||||
|
||||
if ($requiredApprovals !== null)
|
||||
{
|
||||
$data->required_approvals = $requiredApprovals;
|
||||
}
|
||||
|
||||
if ($statusCheckContexts !== null)
|
||||
{
|
||||
$data->status_check_contexts = $statusCheckContexts;
|
||||
}
|
||||
|
||||
if ($unprotectedFilePatterns !== null)
|
||||
{
|
||||
$data->unprotected_file_patterns = $unprotectedFilePatterns;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Collaborator
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Collaborator extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's collaborators.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the page and limit variables.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is a collaborator of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a collaborator to a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
* @param string $permission The permission level for the collaborator (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator,
|
||||
string $permission = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Prepare the request body.
|
||||
$body = new stdClass();
|
||||
if ($permission !== null) {
|
||||
$body->permission = $permission;
|
||||
}
|
||||
$bodyJson = json_encode($body);
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put($uri, $bodyJson), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a collaborator from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repository permissions for a user.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function permission(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}/permission";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
225
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Commits.php
Normal file
225
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Commits.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Commit
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Commits extends Api
|
||||
{
|
||||
/**
|
||||
* Get a list of all commits from a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string|null $sha SHA or branch to start listing commits from (usually 'master').
|
||||
* @param string|null $path Filepath of a file/dir.
|
||||
* @param bool|null $stat Include diff stats for every commit (disable for speedup, default 'true').
|
||||
* @param int|null $page Page number of results to return (1-based).
|
||||
* @param int|null $limit Page size of results (ignored if used with 'path').
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getList(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?string $sha = null,
|
||||
?string $path = null,
|
||||
?bool $stat = true,
|
||||
?int $page = 1,
|
||||
?int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/commits";
|
||||
|
||||
// Set query parameters.
|
||||
$uri = $this->uri->get($uriPath);
|
||||
|
||||
if ($sha !== null)
|
||||
{
|
||||
$uri->setVar('sha', $sha);
|
||||
}
|
||||
|
||||
if ($path !== null)
|
||||
{
|
||||
$uri->setVar('path', $path);
|
||||
}
|
||||
|
||||
if ($stat !== null)
|
||||
{
|
||||
$uri->setVar('stat', $stat ? 'true' : 'false');
|
||||
}
|
||||
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single commit from a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $sha A git ref or commit sha.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCommit(string $owner, string $repo, string $sha): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/git/commits/{$sha}";
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($uriPath)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a commit's combined status, by branch/tag/commit reference.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $ref The branch, tag, or commit reference.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function status(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/commits/{$ref}/status";
|
||||
|
||||
// Set up the URI with the required parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a commit's statuses, by branch/tag/commit reference.
|
||||
*
|
||||
* @param string $owner The owner of the repository.
|
||||
* @param string $repo The name of the repository.
|
||||
* @param string $ref The branch, tag, or commit reference.
|
||||
* @param string $sort The type of sort. Available values: oldest, recentupdate, leastupdate, leastindex, highestindex.
|
||||
* @param string $state The type of state. Available values: pending, success, error, failure, warning.
|
||||
* @param int $page The page number of results to return (1-based). Default value: 1.
|
||||
* @param int $limit The page size of results. Default value: 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function statuses(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref,
|
||||
string $sort = null,
|
||||
string $state = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/commits/{$ref}/statuses";
|
||||
|
||||
// Add query parameters to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($sort !== null)
|
||||
{
|
||||
$uri->setVar('sort', $sort);
|
||||
}
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$uri->setVar('state', $state);
|
||||
}
|
||||
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the GET request.
|
||||
$response = $this->http->get($uri);
|
||||
return $this->response->get($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a commit's diff or patch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The SHA hash of the commit.
|
||||
* @param string $diffType The diff type, either 'diff' or 'patch'.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function diff(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $sha,
|
||||
string $diffType
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/commits/{$sha}";
|
||||
|
||||
// Set the diffType as a variable in the URI.
|
||||
$this->uri->setVar('diffType', $diffType);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,511 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Contents
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Contents extends Api
|
||||
{
|
||||
/**
|
||||
* Get a file from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string|null $ref Optional. The name of the commit/branch/tag.
|
||||
* Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $filepath, ?string $ref = null)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/raw/{$filepath}";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the ref parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata and contents (if a file) of an entry in a repository,
|
||||
* or a list of entries if a directory.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file or directory path.
|
||||
* @param string|null $ref Optional. The name of the commit/branch/tag.
|
||||
* Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the ref parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $content The file content.
|
||||
* @param string $message The commit message.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string|null $authorName The author's name.
|
||||
* @param string|null $authorEmail The author's email.
|
||||
* @param string|null $committerName The committer's name.
|
||||
* @param string|null $committerEmail The committer's email.
|
||||
* @param bool|null $newBranch Whether to create a new branch. Defaults to false.
|
||||
* @param string|null $authorDate The author's date.
|
||||
* @param string|null $committerDate The committer's date.
|
||||
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $content,
|
||||
string $message,
|
||||
string $branch = 'master',
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?bool $newBranch = false,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the post data
|
||||
$data = new \stdClass();
|
||||
$data->content = base64_encode($content);
|
||||
$data->message = $message;
|
||||
$data->branch = $branch;
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata of all the entries of the root directory.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function root(string $owner, string $repo, ?string $ref = null): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the 'ref' parameter if it's provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$uri
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $content The file content.
|
||||
* @param string $message The commit message.
|
||||
* @param string $sha The blob SHA of the file.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string|null $authorName The author name. Defaults to the authenticated user.
|
||||
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
|
||||
* @param string|null $committerName The committer name. Defaults to the authenticated user.
|
||||
* @param string|null $committerEmail The committer email. Defaults to the authenticated user.
|
||||
* @param string|null $authorDate The author date.
|
||||
* @param string|null $committerDate The committer date.
|
||||
* @param string|null $fromPath The original file path to move/rename.
|
||||
* @param string|null $newBranch The new branch to create from the specified branch.
|
||||
* @param bool|null $signoff Add a Signed-off-by trailer.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $content,
|
||||
string $message,
|
||||
string $sha,
|
||||
string $branch = 'master',
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?string $fromPath = null,
|
||||
?string $newBranch = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the file data.
|
||||
$data = new \stdClass();
|
||||
$data->content = base64_encode($content);
|
||||
$data->message = $message;
|
||||
$data->branch = $branch;
|
||||
$data->sha = $sha;
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fromPath !== null)
|
||||
{
|
||||
$data->from_path = $fromPath;
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $message The commit message.
|
||||
* @param string $branch The branch name (optional).
|
||||
* @param string $sha The blob SHA of the file.
|
||||
* @param string $authorName The author name (optional).
|
||||
* @param string $authorEmail The author email (optional).
|
||||
* @param string $committerName The committer name (optional).
|
||||
* @param string $committerEmail The committer email (optional).
|
||||
* @param string $authorDate The author date (optional).
|
||||
* @param string $committerDate The committer date (optional).
|
||||
* @param string $newBranch The new branch name (optional).
|
||||
* @param bool $signoff Add a Signed-off-by trailer (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $message,
|
||||
string $sha,
|
||||
?string $branch = null,
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?string $newBranch = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the file data.
|
||||
$data = new \stdClass();
|
||||
$data->message = $message;
|
||||
$data->sha = $sha;
|
||||
|
||||
if ($branch !== null) {
|
||||
$data->branch = $branch;
|
||||
}
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EditorConfig definitions of a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $ref The name of the commit/branch/tag.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/editorconfig/{$filepath}";
|
||||
|
||||
// Set the request parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the blob of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The SHA hash of the blob.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function blob(string $owner, string $repo, string $sha): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/blobs/{$sha}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
102
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Forks.php
Normal file
102
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Forks.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Forks
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Forks extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's forks.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function listForks(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/forks";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($uriPath);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fork a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $forkName The name of the forked repository (optional).
|
||||
* @param string $organization The organization name (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function repo(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $forkName = '',
|
||||
string $organization = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/forks";
|
||||
|
||||
// Set the fork data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if (!empty($forkName))
|
||||
{
|
||||
$data->name = $forkName;
|
||||
}
|
||||
|
||||
if (!empty($organization))
|
||||
{
|
||||
$data->organization = $organization;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 202
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
48
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Gpg.php
Normal file
48
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Gpg.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Gpg
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gpg extends Api
|
||||
{
|
||||
/**
|
||||
* Get signing-key.gpg for a given repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $ownerName, string $repoName): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/signing-key.gpg";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
214
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Hooks.php
Normal file
214
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Hooks.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Hooks
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Hooks extends Api
|
||||
{
|
||||
/**
|
||||
* List the hooks in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks";
|
||||
|
||||
// Set up the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $type The hook type.
|
||||
* @param array $config The hook configuration.
|
||||
* @param bool $active The hook's active status (optional, default: false).
|
||||
* @param array|null $events The events for the hook (optional).
|
||||
* @param string $branchFilter The branch filter (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $type,
|
||||
array $config,
|
||||
string $type,
|
||||
array $config,
|
||||
bool $active = false,
|
||||
?array $events = null,
|
||||
string $branchFilter = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->type = $type;
|
||||
$data->config = (object) $config;
|
||||
$data->active = $active;
|
||||
|
||||
if ($events !== null)
|
||||
{
|
||||
$data->events = $events;
|
||||
}
|
||||
|
||||
if (!empty($branchFilter))
|
||||
{
|
||||
$data->branch_filter = $branchFilter;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a hook.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $hookId The hook ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $hookId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$hookId}";
|
||||
|
||||
// Get the URI for the request path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The hook ID.
|
||||
* @param array $config The hook configuration.
|
||||
* @param array $events The events to trigger the hook.
|
||||
* @param bool $active Whether the hook is active.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
array $config,
|
||||
array $events,
|
||||
bool $active
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$id}";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->config = $config;
|
||||
$data->events = $events;
|
||||
$data->active = $active;
|
||||
|
||||
// Send the PATCH request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a push webhook.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $hookId The hook ID.
|
||||
* @param string $ref The name of the commit/branch/tag (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function test(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $hookId,
|
||||
string $ref = ''
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$hookId}/tests";
|
||||
|
||||
// Get the URI for the request path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if (!empty($ref))
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository\Hooks;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Hooks Git
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Git extends Api
|
||||
{
|
||||
/**
|
||||
* List the Git hooks in a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $ownerName, string $repoName): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/hooks/git";
|
||||
|
||||
// Get the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Git hook.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $hookId The Git hook ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $hookId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/hooks/git/{$hookId}";
|
||||
|
||||
// Get the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Git hook in a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repositoryName The repository name.
|
||||
* @param string $hookId The Git hook ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repositoryName,
|
||||
string $hookId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repositoryName}/hooks/git/{$hookId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Git hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $hookId The Git hook ID.
|
||||
* @param array $hookOptions The hook configuration.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $hookId,
|
||||
array $hookOptions
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/git/{$hookId}";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->config = (object) $hookOptions;
|
||||
|
||||
// Send the PATCH request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
159
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Keys.php
Normal file
159
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Keys.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Keys
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Keys extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's keys.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int|null $keyId The key_id to search for. (Optional)
|
||||
* @param string|null $fingerprint The fingerprint of the key. (Optional)
|
||||
* @param int $page The page number of results to return. (Default: 1)
|
||||
* @param int $limit The page size of results. (Default: 10)
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(string $owner, string $repo, ?int $keyId = null, ?string $fingerprint = null, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the optional query parameters.
|
||||
if ($keyId !== null)
|
||||
{
|
||||
$uri->setVar('key_id', $keyId);
|
||||
}
|
||||
|
||||
if ($fingerprint !== null)
|
||||
{
|
||||
$uri->setVar('fingerprint', $fingerprint);
|
||||
}
|
||||
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a key to a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $key The public key.
|
||||
* @param string $title The title of the key.
|
||||
* @param bool $readOnly Whether the key is read-only.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $key,
|
||||
string $title,
|
||||
bool $readOnly
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys";
|
||||
|
||||
// Set the key data.
|
||||
$data = new \stdClass();
|
||||
$data->key = $key;
|
||||
$data->title = $title;
|
||||
$data->read_only = $readOnly;
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a repository's key by id.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The key ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function id(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys/{$id}";
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a key from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The key ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys/{$id}";
|
||||
|
||||
// Send the DELETE request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Languages
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Languages extends Api
|
||||
{
|
||||
/**
|
||||
* Get languages and number of bytes of code written in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getLanguages(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/languages";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Media
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Media extends Api
|
||||
{
|
||||
/**
|
||||
* Get a file or its LFS object from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string|null $ref The name of the commit/branch/tag. (Optional)
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
?string $ref = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$encodedFilepath = rawurlencode($filepath);
|
||||
$path = "/repos/{$owner}/{$repo}/media/{$encodedFilepath}";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the 'ref' query parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
167
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Merge.php
Normal file
167
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Merge.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Merge
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Merge extends Api
|
||||
{
|
||||
/**
|
||||
* Check if a pull request has been merged.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $mergeMethod Merge method to use (optional).
|
||||
* @param string|null $mergeCommitId Merge commit ID (optional).
|
||||
* @param string|null $mergeMessageField Merge message field (optional).
|
||||
* @param string|null $mergeTitleField Merge title field (optional).
|
||||
* @param bool|null $deleteBranchAfterMerge Delete branch after merge (optional).
|
||||
* @param bool|null $forceMerge Force merge (optional).
|
||||
* @param string|null $headCommitId Head commit ID (optional).
|
||||
* @param bool|null $mergeWhenChecksSucceed Merge when checks succeed (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function pull(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $mergeMethod = null,
|
||||
?string $mergeCommitId = null,
|
||||
?string $mergeMessageField = null,
|
||||
?string $mergeTitleField = null,
|
||||
?bool $deleteBranchAfterMerge = null,
|
||||
?bool $forceMerge = null,
|
||||
?string $headCommitId = null,
|
||||
?bool $mergeWhenChecksSucceed = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($mergeMethod !== null)
|
||||
{
|
||||
$data->do = $mergeMethod;
|
||||
}
|
||||
|
||||
if ($mergeCommitId !== null)
|
||||
{
|
||||
$data->merge_commit_id = $mergeCommitId;
|
||||
}
|
||||
|
||||
if ($mergeMessageField !== null)
|
||||
{
|
||||
$data->merge_message_field = $mergeMessageField;
|
||||
}
|
||||
|
||||
if ($mergeTitleField !== null)
|
||||
{
|
||||
$data->merge_title_field = $mergeTitleField;
|
||||
}
|
||||
|
||||
if ($deleteBranchAfterMerge !== null)
|
||||
{
|
||||
$data->delete_branch_after_merge = $deleteBranchAfterMerge;
|
||||
}
|
||||
|
||||
if ($forceMerge !== null)
|
||||
{
|
||||
$data->force_merge = $forceMerge;
|
||||
}
|
||||
|
||||
if ($headCommitId !== null)
|
||||
{
|
||||
$data->head_commit_id = $headCommitId;
|
||||
}
|
||||
|
||||
if ($mergeWhenChecksSucceed !== null)
|
||||
{
|
||||
$data->merge_when_checks_succeed = $mergeWhenChecksSucceed;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the scheduled auto merge for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function cancel(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Mirror
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Mirror extends Api
|
||||
{
|
||||
/**
|
||||
* Sync a mirrored repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function sync(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/mirror-sync";
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
190
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Mirrors.php
Normal file
190
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Mirrors.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Mirrors
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Mirrors extends Api
|
||||
{
|
||||
/**
|
||||
* Get all push mirrors of the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors";
|
||||
|
||||
// Set query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a push mirror to the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $remoteAddress The push mirror address.
|
||||
* @param string|null $remoteUsername The push mirror user. (Optional)
|
||||
* @param string|null $remotePassword The push mirror password. (Optional)
|
||||
* @param string $interval The interval for the push mirror.
|
||||
* @param bool $syncOnCommit Sync on commit option.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $remoteAddress,
|
||||
?string $remoteUsername = null,
|
||||
?string $remotePassword = null,
|
||||
string $interval,
|
||||
bool $syncOnCommit
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors";
|
||||
|
||||
// Set the mirror data.
|
||||
$data = new \stdClass();
|
||||
$data->remote_address = $remoteAddress;
|
||||
$data->interval = $interval;
|
||||
$data->sync_on_commit = $syncOnCommit;
|
||||
|
||||
if ($remoteUsername !== null)
|
||||
{
|
||||
$data->remote_username = $remoteUsername;
|
||||
}
|
||||
|
||||
if ($remotePassword !== null)
|
||||
{
|
||||
$data->remote_password = $remotePassword;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync all push mirrored repositories.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function sync(
|
||||
string $owner,
|
||||
string $repo
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors-sync";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get push mirror of the repository by remoteName.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The remote name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function name(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a push mirror from a repository by remoteName.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The remote name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Notes
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Notes extends Api
|
||||
{
|
||||
/**
|
||||
* Get a note corresponding to a single commit from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $commitSha The SHA hash of the commit.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $commitSha
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/notes/{$commitSha}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Patch
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Patch extends Api
|
||||
{
|
||||
/**
|
||||
* Apply a diff patch to a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param array $options Options for updating files.
|
||||
* $options = [
|
||||
* 'description' => 'UpdateFileOptions',
|
||||
* 'body' => [
|
||||
* 'content' => 'string', // Content must be base64 encoded.
|
||||
* 'sha' => 'string', // The SHA for the file that already exists.
|
||||
* 'branch' => 'string', // Branch (optional) to base this file from. If not given, the default branch is used.
|
||||
* 'new_branch' => 'string', // New branch (optional) will make a new branch from branch before creating the file.
|
||||
* 'from_path' => 'string', // From_path (optional) is the path of the original file which will be moved/renamed to the path in the URL.
|
||||
* 'message' => 'string', // Message (optional) for the commit of this file. If not supplied, a default message will be used.
|
||||
* 'author' => [ // Identity for a person's identity like an author or committer.
|
||||
* 'name' => 'string',
|
||||
* 'email' => 'string($email)'
|
||||
* ],
|
||||
* 'committer' => [ // Identity for a person's identity like an author or committer.
|
||||
* 'name' => 'string',
|
||||
* 'email' => 'string($email)'
|
||||
* ],
|
||||
* 'dates' => [ // Store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE.
|
||||
* 'author' => 'string($date-time)',
|
||||
* 'committer' => 'string($date-time)'
|
||||
* ],
|
||||
* 'signoff' => 'boolean' // Add a Signed-off-by trailer by the committer at the end of the commit log message.
|
||||
* ]
|
||||
* ]
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function applyDiffPatch(
|
||||
string $owner,
|
||||
string $repo,
|
||||
array $option
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/diffpatch";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($uriPath),
|
||||
json_encode($options)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
547
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Pulls.php
Normal file
547
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Pulls.php
Normal file
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Pulls
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Pulls extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's pull requests.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string|null $state State of pull request: open, closed, or all (optional).
|
||||
* @param string|null $sort Type of sort (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int $page Page number of results to return (1-based, default: 1).
|
||||
* @param int $limit Page size of results (default: 10).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?string $state = null,
|
||||
?string $sort = null,
|
||||
?int $milestone = null,
|
||||
?array $labels = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls";
|
||||
|
||||
// Set query parameters.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$this->uri->setVar('state', $state);
|
||||
}
|
||||
|
||||
if ($sort !== null)
|
||||
{
|
||||
$this->uri->setVar('sort', $sort);
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$this->uri->setVar('milestone', $milestone);
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$this->uri->setVar('labels', implode(',', $labels));
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $title The title of the pull request.
|
||||
* @param string $head The head branch.
|
||||
* @param string $base The base branch.
|
||||
* @param string|null $body The description of the pull request (optional).
|
||||
* @param string|null $assignee The assignee of the pull request (optional).
|
||||
* @param array|null $assignees Additional assignees (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param string|null $dueDate Due date of the pull request (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $title,
|
||||
string $head,
|
||||
string $base,
|
||||
?string $body = null,
|
||||
?string $assignee = null,
|
||||
?array $assignees = null,
|
||||
?array $labels = null,
|
||||
?int $milestone = null,
|
||||
?string $dueDate = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls";
|
||||
|
||||
// Set the pull request data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $title;
|
||||
$data->head = $head;
|
||||
$data->base = $base;
|
||||
|
||||
if ($body !== null)
|
||||
{
|
||||
$data->body = $body;
|
||||
}
|
||||
|
||||
if ($assignee !== null)
|
||||
{
|
||||
$data->assignee = $assignee;
|
||||
}
|
||||
|
||||
if ($assignees !== null)
|
||||
{
|
||||
$data->assignees = $assignees;
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$data->labels = $labels;
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$data->milestone = $milestone;
|
||||
}
|
||||
|
||||
if ($dueDate !== null)
|
||||
{
|
||||
$data->due_date = $dueDate;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, int $index): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $title The title of the pull request (optional).
|
||||
* @param string|null $body The description of the pull request (optional).
|
||||
* @param string|null $assignee The assignee of the pull request (optional).
|
||||
* @param array|null $assignees Additional assignees (optional).
|
||||
* @param string|null $base The base branch (optional).
|
||||
* @param string|null $state The state of the pull request (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param string|null $dueDate Due date of the pull request (optional).
|
||||
* @param bool|null $unsetDueDate Whether to unset the due date (optional).
|
||||
* @param bool|null $allowMaintainerEdit Allow maintainer to edit the pull request (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $title = null,
|
||||
?string $body = null,
|
||||
?string $assignee = null,
|
||||
?array $assignees = null,
|
||||
?string $base = null,
|
||||
?string $state = null,
|
||||
?array $labels = null,
|
||||
?int $milestone = null,
|
||||
?string $dueDate = null,
|
||||
?bool $unsetDueDate = null,
|
||||
?bool $allowMaintainerEdit = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}";
|
||||
|
||||
// Set the pull request data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($title !== null)
|
||||
{
|
||||
$data->title = $title;
|
||||
}
|
||||
|
||||
if ($body !== null)
|
||||
{
|
||||
$data->body = $body;
|
||||
}
|
||||
|
||||
if ($assignee !== null)
|
||||
{
|
||||
$data->assignee = $assignee;
|
||||
}
|
||||
|
||||
if ($assignees !== null)
|
||||
{
|
||||
$data->assignees = $assignees;
|
||||
}
|
||||
|
||||
if ($base !== null)
|
||||
{
|
||||
$data->base = $base;
|
||||
}
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$data->state = $state;
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$data->labels = $labels;
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$data->milestone = $milestone;
|
||||
}
|
||||
|
||||
if ($dueDate !== null)
|
||||
{
|
||||
$data->due_date = $dueDate;
|
||||
}
|
||||
|
||||
if ($unsetDueDate !== null)
|
||||
{
|
||||
$data->unset_due_date = $unsetDueDate;
|
||||
}
|
||||
|
||||
if ($allowMaintainerEdit !== null)
|
||||
{
|
||||
$data->allow_maintainer_edit = $allowMaintainerEdit;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pull request diff or patch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $diffType The type of the requested data, either "diff" or "patch".
|
||||
* @param bool $binary Whether to include binary file changes. If true, the diff is applicable with git apply.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function diff(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
string $diffType,
|
||||
bool $binary = false
|
||||
): string
|
||||
{
|
||||
// Validate the diff type.
|
||||
if (!in_array($diffType, ['diff', 'patch']))
|
||||
{
|
||||
throw new \InvalidArgumentException('Invalid diff type. Allowed types are "diff" and "patch".');
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}.{$diffType}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the binary query parameter if required.
|
||||
if ($binary)
|
||||
{
|
||||
$uri->setVar('binary', 'true');
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commits for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function commits(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/commits";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the page and limit query parameters.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get changed files for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $skipTo Skip to the given file.
|
||||
* @param string $whitespace Whitespace behavior.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function files(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $skipTo = null,
|
||||
?string $whitespace = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/files";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the skip-to, whitespace, page, and limit query parameters if needed.
|
||||
if ($skipTo !== null)
|
||||
{
|
||||
$uri->setVar('skip-to', $skipTo);
|
||||
}
|
||||
if ($whitespace !== null)
|
||||
{
|
||||
$uri->setVar('whitespace', $whitespace);
|
||||
}
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $do Merge method.
|
||||
* @param string|null $mergeCommitId Merge commit ID.
|
||||
* @param string|null $mergeMessageField Merge message field.
|
||||
* @param string|null $mergeTitleField Merge title field.
|
||||
* @param bool|null $deleteBranchAfterMerge Whether to delete the branch after merge.
|
||||
* @param bool|null $forceMerge Whether to force merge.
|
||||
* @param string|null $headCommitId Head commit ID.
|
||||
* @param bool|null $mergeWhenChecksSucceed Whether to merge when checks succeed.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function merge(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $do = null,
|
||||
?string $mergeCommitId = null,
|
||||
?string $mergeMessageField = null,
|
||||
?string $mergeTitleField = null,
|
||||
?bool $deleteBranchAfterMerge = null,
|
||||
?bool $forceMerge = null,
|
||||
?string $headCommitId = null,
|
||||
?bool $mergeWhenChecksSucceed = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($do !== null)
|
||||
{
|
||||
$data->do = $do;
|
||||
}
|
||||
|
||||
if ($mergeCommitId !== null)
|
||||
{
|
||||
$data->merge_commit_id = $mergeCommitId;
|
||||
}
|
||||
|
||||
if ($mergeMessageField !== null)
|
||||
{
|
||||
$data->merge_message_field = $mergeMessageField;
|
||||
}
|
||||
|
||||
if ($mergeTitleField !== null)
|
||||
{
|
||||
$data->merge_title_field = $mergeTitleField;
|
||||
}
|
||||
|
||||
if ($deleteBranchAfterMerge !== null)
|
||||
{
|
||||
$data->delete_branch_after_merge = $deleteBranchAfterMerge;
|
||||
}
|
||||
|
||||
if ($forceMerge !== null)
|
||||
{
|
||||
$data->force_merge = $forceMerge;
|
||||
}
|
||||
|
||||
if ($headCommitId !== null)
|
||||
{
|
||||
$data->head_commit_id = $headCommitId;
|
||||
}
|
||||
|
||||
if ($mergeWhenChecksSucceed !== null)
|
||||
{
|
||||
$data->merge_when_checks_succeed = $mergeWhenChecksSucceed;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge PR's baseBranch into headBranch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $style How to update the pull request. (Optional)
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $style = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/update";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($style !== null)
|
||||
{
|
||||
$data->style = $style;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Refs
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Refs extends Api
|
||||
{
|
||||
/**
|
||||
* Get specified ref or filtered repository's refs.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/refs";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specified ref.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $ref The ref name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/refs/{$ref}";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Releases
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Releases extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's releases.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param bool|null $draft Filter (exclude/include) drafts (optional).
|
||||
* @param bool|null $preRelease Filter (exclude/include) pre-releases (optional).
|
||||
* @param int $page Page number of results to return (1-based, optional).
|
||||
* @param int $limit Page size of results (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
?bool $draft = null,
|
||||
?bool $preRelease = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases";
|
||||
|
||||
// Set additional URI values.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
if ($draft !== null)
|
||||
{
|
||||
$this->uri->setVar('draft', $draft);
|
||||
}
|
||||
|
||||
if ($preRelease !== null)
|
||||
{
|
||||
$this->uri->setVar('pre-release', $preRelease);
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a release.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
* @param string $targetCommitish The commitish value that determines where the Git tag is created from.
|
||||
* @param string $releaseName The name of the release.
|
||||
* @param string $releaseBody The description of the release.
|
||||
* @param bool $isDraft Whether the release is a draft.
|
||||
* @param bool $isPrerelease Whether the release is a pre-release.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName,
|
||||
string $targetCommitish,
|
||||
string $releaseName,
|
||||
string $releaseBody,
|
||||
bool $isDraft = false,
|
||||
bool $isPrerelease = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases";
|
||||
|
||||
// Set the release data
|
||||
$data = new \stdClass();
|
||||
$data->tag_name = $tagName;
|
||||
$data->target_commitish = $targetCommitish;
|
||||
$data->name = $releaseName;
|
||||
$data->body = $releaseBody;
|
||||
$data->draft = $isDraft;
|
||||
$data->prerelease = $isPrerelease;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release by ID.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release by ID.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a release.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
* @param string|null $tagName The tag name (optional).
|
||||
* @param string|null $targetCommitish The commitish value that determines where the Git tag is created from (optional).
|
||||
* @param string|null $releaseName The name of the release (optional).
|
||||
* @param string|null $description The description of the release (optional).
|
||||
* @param bool|null $isDraft Whether the release is a draft (optional).
|
||||
* @param bool|null $isPrerelease Whether the release is a pre-release (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId,
|
||||
?string $tagName = null,
|
||||
?string $targetCommitish = null,
|
||||
?string $releaseName = null,
|
||||
?string $description = null,
|
||||
?bool $isDraft = null,
|
||||
?bool $isPrerelease = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Set the release data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($tagName !== null || $targetCommitish !== null || $releaseName !== null || $description !== null || $isDraft !== null || $isPrerelease !== null)
|
||||
{
|
||||
$data->editReleaseOption = new \stdClass();
|
||||
|
||||
if ($tagName !== null)
|
||||
{
|
||||
$data->editReleaseOption->tag_name = $tagName;
|
||||
}
|
||||
|
||||
if ($targetCommitish !== null)
|
||||
{
|
||||
$data->editReleaseOption->target_commitish = $targetCommitish;
|
||||
}
|
||||
|
||||
if ($releaseName !== null)
|
||||
{
|
||||
$data->editReleaseOption->name = $releaseName;
|
||||
}
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->editReleaseOption->body = $description;
|
||||
}
|
||||
|
||||
if ($isDraft !== null)
|
||||
{
|
||||
$data->editReleaseOption->draft = $isDraft;
|
||||
}
|
||||
|
||||
if ($isPrerelease !== null)
|
||||
{
|
||||
$data->editReleaseOption->prerelease = $isPrerelease;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release by tag name.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getByTag(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}";
|
||||
|
||||
// Configure the URI with the path.
|
||||
$this->uri->setVar('owner', $ownerName);
|
||||
$this->uri->setVar('repo', $repoName);
|
||||
$this->uri->setVar('tag', $tagName);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release by tag name.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function deleteByTag(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Remote
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Remote extends Api
|
||||
{
|
||||
/**
|
||||
* Migrate a remote git repository.
|
||||
*
|
||||
* @param string $cloneAddr The URL to clone the repository from.
|
||||
* @param string $repoName The desired name for the new repository.
|
||||
* @param string $repoOwner The name of the user or organization who will own the repo after migration.
|
||||
* @param string $uid The ID of the user that will own the new repository (deprecated).
|
||||
* @param string $description The description for the new repository (optional).
|
||||
* @param bool $private Set the repository to private (optional, default false).
|
||||
* @param string|null $authToken Authentication token (optional).
|
||||
* @param string|null $authUsername Authentication username (optional).
|
||||
* @param string|null $authPassword Authentication password (optional).
|
||||
* @param array $options Additional migration options (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function migrate(
|
||||
string $cloneAddr,
|
||||
string $repoName,
|
||||
string $repoOwner,
|
||||
string $uid,
|
||||
string $description = '',
|
||||
bool $private = false,
|
||||
?string $authToken = null,
|
||||
?string $authUsername = null,
|
||||
?string $authPassword = null,
|
||||
array $options = []
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/migrate";
|
||||
|
||||
// Set the repository migration data.
|
||||
$data = new \stdClass();
|
||||
$data->cloneAddr = $cloneAddr;
|
||||
$data->repoName = $repoName;
|
||||
$data->repoOwner = $repoOwner;
|
||||
$data->uid = $uid;
|
||||
$data->description = $description;
|
||||
$data->private = $private;
|
||||
|
||||
if ($authToken !== null)
|
||||
{
|
||||
$data->authToken = $authToken;
|
||||
}
|
||||
|
||||
if ($authUsername !== null)
|
||||
{
|
||||
$data->authUsername = $authUsername;
|
||||
}
|
||||
|
||||
if ($authPassword !== null)
|
||||
{
|
||||
$data->authPassword = $authPassword;
|
||||
}
|
||||
|
||||
foreach ($options as $key => $val)
|
||||
{
|
||||
$data->{$key} = $val;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Reviewers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Reviewers extends Api
|
||||
{
|
||||
/**
|
||||
* Create review requests for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param array $reviewers Array of reviewers usernames.
|
||||
* @param array|null $teamReviewers Array of team reviewers (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function request(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
array $reviewers,
|
||||
?array $teamReviewers = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers";
|
||||
|
||||
// Set the review requests data.
|
||||
$data = new \stdClass();
|
||||
$data->reviewers = $reviewers;
|
||||
|
||||
if ($teamReviewers !== null)
|
||||
{
|
||||
$data->team_reviewers = $teamReviewers;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel review requests for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param array $reviewers Array of reviewers usernames.
|
||||
* @param array|null $teamReviewers Array of team reviewers (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function cancel(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
array $reviewers,
|
||||
?array $teamReviewers = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers";
|
||||
|
||||
// Get the URI and set the required variables.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('reviewers', json_encode($reviewers));
|
||||
|
||||
if ($teamReviewers !== null)
|
||||
{
|
||||
$uri->setVar('teamReviewers', json_encode($teamReviewers));
|
||||
}
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all users that can be requested to review in this repo.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/reviewers";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
321
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Reviews.php
Normal file
321
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Reviews.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Reviews
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Reviews extends Api
|
||||
{
|
||||
/**
|
||||
* List all reviews for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews";
|
||||
|
||||
// Get the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set query parameters.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $body The review body text.
|
||||
* @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT).
|
||||
* @param array|null $comments An array of CreatePullReviewComment objects.
|
||||
* @param string|null $commitId The commit ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
string $body,
|
||||
string $event,
|
||||
?array $comments = null,
|
||||
?string $commitId = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews";
|
||||
|
||||
// Set the review data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $body;
|
||||
$data->event = $event;
|
||||
|
||||
// Add comments if available.
|
||||
if ($comments !== null)
|
||||
{
|
||||
$data->comments = $comments;
|
||||
}
|
||||
|
||||
// Add commitId if available.
|
||||
if ($commitId !== null)
|
||||
{
|
||||
$data->commit_id = $commitId;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a pending review to a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
* @param string $body The review body text.
|
||||
* @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function submit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id,
|
||||
string $body,
|
||||
string $event
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the review data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $body;
|
||||
$data->event = $event;
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific review from a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comments of a specific review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function comments(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/comments";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
* @param string $message The dismissal message.
|
||||
* @param bool $priors The flag to dismiss prior reviews.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function dismiss(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id,
|
||||
string $message,
|
||||
bool $priors = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/dismissals";
|
||||
|
||||
// Set the dismissal data.
|
||||
$data = new \stdClass();
|
||||
$data->message = $message;
|
||||
$data->priors = $priors;
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the dismissal of a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function undismiss(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/undismissals";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Stargazers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Stargazers extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's stargazers.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/stargazers";
|
||||
|
||||
// Set the page and limit values.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Statuses
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Statuses extends Api
|
||||
{
|
||||
/**
|
||||
* Get a commit's statuses.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $commitSha The commit SHA.
|
||||
* @param string $sort The type of sort.
|
||||
* @param string $state The type of state.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $commitSha,
|
||||
string $sort = 'recentupdate',
|
||||
string $state = 'pending',
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the query parameters.
|
||||
$uri->setVar('sort', $sort);
|
||||
$uri->setVar('state', $state);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a commit status.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $commitSha The commit SHA.
|
||||
* @param string $state The commit status state (error, failure, pending, success, or warning).
|
||||
* @param string|null $context The context of the status (optional).
|
||||
* @param string|null $statusDescription The status description (optional).
|
||||
* @param string|null $targetUrl The URL of the associated build status (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $commitSha,
|
||||
string $state,
|
||||
?string $context = null,
|
||||
?string $statusDescription = null,
|
||||
?string $targetUrl = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}";
|
||||
|
||||
// Set the commit status data
|
||||
$data = new \stdClass();
|
||||
$data->state = $state;
|
||||
|
||||
if ($context !== null)
|
||||
{
|
||||
$data->context = $context;
|
||||
}
|
||||
|
||||
if ($statusDescription !== null)
|
||||
{
|
||||
$data->description = $statusDescription;
|
||||
}
|
||||
|
||||
if ($targetUrl !== null)
|
||||
{
|
||||
$data->target_url = $targetUrl;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
182
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Tags.php
Normal file
182
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Tags.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Tags
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Tags extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's tags
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param int|null $page The page number of results to return (1-based).
|
||||
* @param int|null $limit The page size of results, default maximum page size is 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?int $page = 1,
|
||||
?int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add query parameters if they are provided.
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag of a repository by tag name.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $tag): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags/{$tag}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag object of an annotated tag (not lightweight tags).
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $sha The sha of the tag. The Git tags API only supports annotated tag objects, not lightweight tags.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function sha(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $sha
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/tags/{$sha}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new git tag in a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $tagName The name of the tag.
|
||||
* @param string $target The SHA of the git object this is tagging.
|
||||
* @param string $message The tag message.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $tagName,
|
||||
string $target,
|
||||
string $message
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags";
|
||||
|
||||
// Set the tag data
|
||||
$data = new \stdClass();
|
||||
$data->tag_name = $tagName;
|
||||
$data->target = $target;
|
||||
$data->message = $message;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a repository's tag by name.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $tag
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags/{$tag}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'succes'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
133
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Teams.php
Normal file
133
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Teams.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Teams
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Teams extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's teams.
|
||||
*
|
||||
* @param string $ownerOfRepo The owner name.
|
||||
* @param string $nameOfRepo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $ownerOfRepo, string $nameOfRepo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerOfRepo}/{$nameOfRepo}/teams";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a team is assigned to a repository.
|
||||
*
|
||||
* @param string $ownerOfRepo The owner name.
|
||||
* @param string $nameOfRepo The repository name.
|
||||
* @param string $teamName The team name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(
|
||||
string $ownerOfRepo,
|
||||
string $nameOfRepo,
|
||||
string $teamName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerOfRepo}/{$nameOfRepo}/teams/{$teamName}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a team to a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $teamName The team name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $teamName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/teams/{$teamName}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a team from a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $teamName The team name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $teamName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/teams/{$teamName}";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri),
|
||||
204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Templates
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Templates extends Api
|
||||
{
|
||||
/**
|
||||
* Get available issue templates for a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function issue(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issue_templates";
|
||||
|
||||
// Get the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a repository using a template.
|
||||
*
|
||||
* @param string $templateOwner The template owner's name.
|
||||
* @param string $templateRepo The template repository name.
|
||||
* @param string $name The name of the new repository.
|
||||
* @param array $options Optional. Additional options for the new repository.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function repo(
|
||||
string $templateOwner,
|
||||
string $templateRepo,
|
||||
string $name,
|
||||
array $options = []
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$templateOwner}/{$templateRepo}/generate";
|
||||
|
||||
// Set the repo data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
|
||||
foreach ($options as $key => $value)
|
||||
{
|
||||
if ($value !== null)
|
||||
{
|
||||
$data->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Times
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Times extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's tracked times.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $user Optional filter by user (available for issue managers).
|
||||
* @param string $since Only show times updated after the given time. This is a timestamp in RFC 3339 format.
|
||||
* @param string $before Only show times updated before the given time. This is a timestamp in RFC 3339 format.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $user = null,
|
||||
string $since = null,
|
||||
string $before = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/times";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$uri->setVar('user', $user);
|
||||
}
|
||||
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
175
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Topics.php
Normal file
175
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Topics.php
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Topics
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Topics extends Api
|
||||
{
|
||||
/**
|
||||
* Get the list of topics that a repository has.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/topics";
|
||||
|
||||
// Set query parameters for pagination.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the list of topics for a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param array $topicNames The new list of topics.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function replace(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
array $topicNames
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/topics";
|
||||
|
||||
// Set the topics data.
|
||||
$data = new \stdClass();
|
||||
$data->topics = $topicNames;
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a topic to a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $topicName The topic to add.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $topicName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/topics/{$topicName}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a topic from a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $topicName The topic to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $topicName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/topics/{$topicName}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search topics via keyword.
|
||||
*
|
||||
* @param string $searchKeyword The keyword to search for.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function search(
|
||||
string $searchKeyword,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/topics/search";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('q', $searchKeyword);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Transfer
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Transfer extends Api
|
||||
{
|
||||
/**
|
||||
* Transfer a repo ownership.
|
||||
*
|
||||
* @param string $owner The current owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $newOwner The new owner's name.
|
||||
* @param array|null $teamIDs Optional. The IDs of the teams that will be granted access.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $newOwner,
|
||||
?array $teamIDs = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/transfer";
|
||||
|
||||
// Set the transfer data.
|
||||
$data = new \stdClass();
|
||||
$data->new_owner = $newOwner;
|
||||
if ($teamIDs !== null)
|
||||
{
|
||||
$data->team_ids = $teamIDs;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 202
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a repo transfer.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function accept(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/transfer/accept";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 202
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject a repo transfer.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function reject(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/transfer/reject";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Trees
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Trees extends Api
|
||||
{
|
||||
/**
|
||||
* Get the tree of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The commit SHA.
|
||||
* @param bool $recursive Show all directories and files.
|
||||
* @param int $page Page number.
|
||||
* @param int $perPage Number of items per page.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $sha,
|
||||
bool $recursive = false,
|
||||
int $page = 1,
|
||||
int $perPage = 30
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/trees/{$sha}";
|
||||
|
||||
// Set URI variables.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('recursive', $recursive);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('per_page', $perPage);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Watchers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Watchers extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's watchers.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/subscribers";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the page and limit query parameters.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user is watching a repo.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(string $ownerName, string $repoName): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/subscription";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch a repo.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param bool $subscribed Determine if notifications should be received from this repository.
|
||||
* @param bool $ignored Determine if all notifications should be blocked from this repository.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function watch(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
bool $subscribed = true,
|
||||
bool $ignored = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/subscription";
|
||||
|
||||
// Set the subscription data
|
||||
$data = new \stdClass();
|
||||
$data->subscribed = $subscribed;
|
||||
$data->ignored = $ignored;
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unwatch a repo.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function unwatch(string $ownerName, string $repoName): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/subscription";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
232
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Wiki.php
Normal file
232
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Wiki.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Wiki
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Wiki extends Api
|
||||
{
|
||||
/**
|
||||
* Create a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $title The title of the wiki page.
|
||||
* @param string $contentBase64 The base64 encoded content of the wiki page.
|
||||
* @param string|null $message Optional commit message summarizing the change.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $title,
|
||||
string $contentBase64,
|
||||
?string $message = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/new";
|
||||
|
||||
// Set the wiki data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $title;
|
||||
$data->content_base64 = $contentBase64;
|
||||
|
||||
if ($message !== null)
|
||||
{
|
||||
$data->message = $message;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}";
|
||||
|
||||
// Set the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all wiki pages.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function pages(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/pages";
|
||||
|
||||
// Set the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}";
|
||||
|
||||
// Get the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param string $title The new title of the wiki page.
|
||||
* @param string $content The new content of the wiki page.
|
||||
* @param string $message The optional commit message summarizing the change.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName,
|
||||
string $title,
|
||||
string $content,
|
||||
string $message = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}";
|
||||
|
||||
// Set the wiki data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $title;
|
||||
$data->content_base64 = base64_encode($content);
|
||||
|
||||
if ($message !== null)
|
||||
{
|
||||
$data->message = $message;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get revisions of a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function revisions(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $pageName,
|
||||
int $page = 1
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/wiki/revisions/{$pageName}";
|
||||
|
||||
// Set the page number.
|
||||
$this->uri->setVar('page', $page);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user