-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGogs.php
More file actions
48 lines (42 loc) · 1.3 KB
/
Gogs.php
File metadata and controls
48 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Utopia\VCS\Adapter\Git;
class Gogs extends Gitea
{
protected string $endpoint = 'http://gogs:3000/api/v1';
/**
* Get Adapter Name
*
* @return string
*/
public function getName(): string
{
return 'gogs';
}
protected function getHookType(): string
{
return 'gogs';
}
/**
* Get commit statuses
*
* Overrides the Gitea implementation to normalise the 'state' field
* returned by Gogs into the 'status' field used by the rest of the
* adapter interface (Gitea changed the JSON key from 'state' to
* 'status', but Gogs still uses 'state').
*
* @param string $owner Owner of the repository
* @param string $repositoryName Name of the repository
* @param string $commitHash SHA of the commit
* @return array<mixed> List of commit statuses
*/
public function getCommitStatuses(string $owner, string $repositoryName, string $commitHash): array
{
$statuses = parent::getCommitStatuses($owner, $repositoryName, $commitHash);
return array_map(function ($status) {
if (isset($status['state']) && !isset($status['status'])) {
$status['status'] = $status['state'];
}
return $status;
}, $statuses);
}
}