Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ services:
required: false
entrypoint: /bin/sh
environment:
- GITEA_ADMIN_USERNAME=${GITEA_ADMIN_USERNAME:-utopia}
- GITEA_ADMIN_USERNAME=${GITEA_ADMIN_USERNAME:-root}
- GITEA_ADMIN_PASSWORD=${GITEA_ADMIN_PASSWORD:-password}
- GITEA_ADMIN_EMAIL=${GITEA_ADMIN_EMAIL:-utopia@example.com}
command: >
Expand Down Expand Up @@ -137,7 +137,7 @@ services:
required: false
entrypoint: /bin/sh
environment:
- FORGEJO_ADMIN_USERNAME=${FORGEJO_ADMIN_USERNAME:-utopia}
- FORGEJO_ADMIN_USERNAME=${FORGEJO_ADMIN_USERNAME:-root}
- FORGEJO_ADMIN_PASSWORD=${FORGEJO_ADMIN_PASSWORD:-password}
- FORGEJO_ADMIN_EMAIL=${FORGEJO_ADMIN_EMAIL:-utopia@example.com}
command: >
Expand Down Expand Up @@ -178,7 +178,7 @@ services:
required: false
entrypoint: /bin/sh
environment:
- GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-utopia}
- GOGS_ADMIN_USERNAME=${GOGS_ADMIN_USERNAME:-root}
- GOGS_ADMIN_PASSWORD=${GOGS_ADMIN_PASSWORD:-password}
- GOGS_ADMIN_EMAIL=${GOGS_ADMIN_EMAIL:-utopia@example.com}
command:
Expand Down
20 changes: 6 additions & 14 deletions src/VCS/Adapter/Git/GitLab.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,28 +555,20 @@ public function getUser(string $username): array

public function getOwnerName(string $installationId, ?int $repositoryId = null): string
{
if ($repositoryId !== null) {
$url = "/projects/{$repositoryId}";
$response = $this->call(self::METHOD_GET, $url, ['PRIVATE-TOKEN' => $this->accessToken]);
$responseHeaders = $response['headers'] ?? [];
$statusCode = $responseHeaders['status-code'] ?? 0;
if ($statusCode >= 400) {
throw new Exception("Failed to get owner name for repository {$repositoryId}: HTTP {$statusCode}");
}
$responseBody = $response['body'] ?? [];
$namespace = $responseBody['namespace'] ?? [];
return $namespace['path'] ?? '';
if ($repositoryId === null || $repositoryId <= 0) {
throw new Exception("repositoryId is required for this adapter");
}

$url = "/user";
$url = "/projects/{$repositoryId}";
$response = $this->call(self::METHOD_GET, $url, ['PRIVATE-TOKEN' => $this->accessToken]);
$responseHeaders = $response['headers'] ?? [];
$statusCode = $responseHeaders['status-code'] ?? 0;
if ($statusCode >= 400) {
throw new Exception("Failed to get current user: HTTP {$statusCode}");
throw new Exception("Failed to get owner name for repository {$repositoryId}: HTTP {$statusCode}");
}
$responseBody = $response['body'] ?? [];
return $responseBody['username'] ?? '';
$namespace = $responseBody['namespace'] ?? [];
return $namespace['path'] ?? '';
}
Comment thread
jaysomani marked this conversation as resolved.

public function getPullRequest(string $owner, string $repositoryName, int $pullRequestNumber): array
Expand Down
8 changes: 1 addition & 7 deletions tests/VCS/Adapter/ForgejoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Utopia\Cache\Adapter\None;
use Utopia\Cache\Cache;
use Utopia\System\System;
use Utopia\VCS\Adapter\Git;
use Utopia\VCS\Adapter\Git\Forgejo;

class ForgejoTest extends GiteaTest
Expand All @@ -18,12 +17,7 @@ class ForgejoTest extends GiteaTest
protected string $webhookSignatureHeader = 'X-Forgejo-Signature';
protected string $avatarDomain = 'http://localhost:3000/avatars/';

protected function createVCSAdapter(): Git
{
return new Forgejo(new Cache(new None()));
}

public function setUp(): void
public function setupAdapter(): void
{
if (empty(static::$accessToken)) {
$this->setupForgejo();
Expand Down
Loading