gitea/src/1dda1c2c-1670-4aea-a6b8-49f.../code.power

52 lines
2.1 KiB
Plaintext

/**
* 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)
)
);
}