Skip to content

Commit d19d4b5

Browse files
committed
updated with small fix
1 parent a1de80e commit d19d4b5

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/VCS/Adapter/Git/Gitea.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public function listRepositoryContents(string $owner, string $repositoryName, st
240240

241241
return $contents;
242242
}
243+
243244
public function deleteRepository(string $owner, string $repositoryName): bool
244245
{
245246
$url = "/repos/{$owner}/{$repositoryName}";

tests/VCS/Adapter/GiteaTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ public function testGetRepositoryTreeWithSlashInBranchName(): void
138138
$repositoryName = 'test-branch-with-slash-' . \uniqid();
139139
$this->vcsAdapter->createRepository(self::$owner, $repositoryName, false);
140140

141-
// Create a file on main branch first
142141
$this->createFile(self::$owner, $repositoryName, 'README.md', '# Test');
143142

144-
// Create a branch with a slash in the name using curl
145143
$giteaUrl = System::getEnv('TESTS_GITEA_URL', 'http://gitea:3000') ?? '';
146144
$url = "{$giteaUrl}/api/v1/repos/" . self::$owner . "/{$repositoryName}/branches";
147145

@@ -156,14 +154,19 @@ public function testGetRepositoryTreeWithSlashInBranchName(): void
156154
'new_branch_name' => 'feature/test-branch',
157155
'old_branch_name' => 'main'
158156
]));
159-
curl_exec($ch);
157+
158+
$response = curl_exec($ch);
159+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
160160
curl_close($ch);
161161

162-
// Now try to get tree from the branch with slash
162+
if ($httpCode >= 400) {
163+
throw new \Exception("Failed to create branch: HTTP {$httpCode}");
164+
}
165+
163166
$tree = $this->vcsAdapter->getRepositoryTree(self::$owner, $repositoryName, 'feature/test-branch');
164167

165168
$this->assertIsArray($tree);
166-
$this->assertNotEmpty($tree); // Should have README.md
169+
$this->assertNotEmpty($tree);
167170
$this->assertContains('README.md', $tree);
168171

169172
$this->vcsAdapter->deleteRepository(self::$owner, $repositoryName);

0 commit comments

Comments
 (0)