Skip to content

Commit 8e62977

Browse files
authored
Exposing GitLab's project metadata (#11734)
* Exposing GitLab's project metadata * Fixed check about GitLab project's metadata initialization
1 parent 6198fc1 commit 8e62977

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Composer/Repository/Vcs/GitLabDriver.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GitLabDriver extends VcsDriver
4343
/**
4444
* @var mixed[] Project data returned by GitLab API
4545
*/
46-
private $project;
46+
private $project = null;
4747

4848
/**
4949
* @var array<string|int, mixed[]> Keeps commits returned by GitLab API as commit id => info
@@ -381,6 +381,10 @@ protected function getReferences(string $type): array
381381

382382
protected function fetchProject(): void
383383
{
384+
if (!is_null($this->project)) {
385+
return;
386+
}
387+
384388
// we need to fetch the default branch from the api
385389
$resource = $this->getApiUrl();
386390
$this->project = $this->getContents($resource, true)->decodeJson();
@@ -581,6 +585,18 @@ public static function supports(IOInterface $io, Config $config, string $url, bo
581585
return true;
582586
}
583587

588+
/**
589+
* Gives back the loaded <gitlab-api>/projects/<owner>/<repo> result
590+
*
591+
* @return mixed[]|null
592+
*/
593+
public function getRepoData(): ?array
594+
{
595+
$this->fetchProject();
596+
597+
return $this->project;
598+
}
599+
584600
protected function getNextPage(Response $response): ?string
585601
{
586602
$header = $response->getHeader('link');

0 commit comments

Comments
 (0)