1
0
Fork 0

Exposing GitLab's project metadata (#11734)

* Exposing GitLab's project metadata

* Fixed check about GitLab project's metadata initialization
pull/11777/head
Roberto Guido 2023-12-20 16:50:24 +01:00 committed by GitHub
parent 6198fc1053
commit 8e62977cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -43,7 +43,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @var mixed[] Project data returned by GitLab API * @var mixed[] Project data returned by GitLab API
*/ */
private $project; private $project = null;
/** /**
* @var array<string|int, mixed[]> Keeps commits returned by GitLab API as commit id => info * @var array<string|int, mixed[]> Keeps commits returned by GitLab API as commit id => info
@ -381,6 +381,10 @@ class GitLabDriver extends VcsDriver
protected function fetchProject(): void protected function fetchProject(): void
{ {
if (!is_null($this->project)) {
return;
}
// we need to fetch the default branch from the api // we need to fetch the default branch from the api
$resource = $this->getApiUrl(); $resource = $this->getApiUrl();
$this->project = $this->getContents($resource, true)->decodeJson(); $this->project = $this->getContents($resource, true)->decodeJson();
@ -581,6 +585,18 @@ class GitLabDriver extends VcsDriver
return true; return true;
} }
/**
* Gives back the loaded <gitlab-api>/projects/<owner>/<repo> result
*
* @return mixed[]|null
*/
public function getRepoData(): ?array
{
$this->fetchProject();
return $this->project;
}
protected function getNextPage(Response $response): ?string protected function getNextPage(Response $response): ?string
{ {
$header = $response->getHeader('link'); $header = $response->getHeader('link');