From 8e62977cb5de315d5190c021a2b2bb4e59ee2f4f Mon Sep 17 00:00:00 2001 From: Roberto Guido Date: Wed, 20 Dec 2023 16:50:24 +0100 Subject: [PATCH] Exposing GitLab's project metadata (#11734) * Exposing GitLab's project metadata * Fixed check about GitLab project's metadata initialization --- src/Composer/Repository/Vcs/GitLabDriver.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 1e13154c5..3721419b1 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -43,7 +43,7 @@ class GitLabDriver extends VcsDriver /** * @var mixed[] Project data returned by GitLab API */ - private $project; + private $project = null; /** * @var array Keeps commits returned by GitLab API as commit id => info @@ -381,6 +381,10 @@ class GitLabDriver extends VcsDriver protected function fetchProject(): void { + if (!is_null($this->project)) { + return; + } + // we need to fetch the default branch from the api $resource = $this->getApiUrl(); $this->project = $this->getContents($resource, true)->decodeJson(); @@ -581,6 +585,18 @@ class GitLabDriver extends VcsDriver return true; } + /** + * Gives back the loaded /projects// result + * + * @return mixed[]|null + */ + public function getRepoData(): ?array + { + $this->fetchProject(); + + return $this->project; + } + protected function getNextPage(Response $response): ?string { $header = $response->getHeader('link');