-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Add Gitea repository content endpoints (tree, content, languages) #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,9 +6,14 @@ | |||||||||||||||||||||||||||||
| use Utopia\Cache\Cache; | ||||||||||||||||||||||||||||||
| use Utopia\VCS\Adapter\Git; | ||||||||||||||||||||||||||||||
| use Utopia\VCS\Exception\RepositoryNotFound; | ||||||||||||||||||||||||||||||
| use Utopia\VCS\Exception\FileNotFound; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class Gitea extends Git | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| public const CONTENTS_FILE = 'file'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public const CONTENTS_DIRECTORY = 'dir'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| protected string $endpoint = 'http://gitea:3000/api/v1'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| protected string $accessToken; | ||||||||||||||||||||||||||||||
|
|
@@ -147,24 +152,94 @@ public function getRepositoryName(string $repositoryId): string | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public function getRepositoryTree(string $owner, string $repositoryName, string $branch, bool $recursive = false): array | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| throw new Exception("Not implemented yet"); | ||||||||||||||||||||||||||||||
| $url = "/repos/{$owner}/{$repositoryName}/git/trees/{$branch}" . ($recursive ? '?recursive=1' : ''); | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Branch names with slashes (for example Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $response = $this->call(self::METHOD_GET, $url, ['Authorization' => "token $this->accessToken"]); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (($response['headers']['status-code'] ?? 0) === 404) { | ||||||||||||||||||||||||||||||
| return []; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return array_column($response['body']['tree'] ?? [], 'path'); | ||||||||||||||||||||||||||||||
|
Comment on lines
153
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for truncated flag handling across the codebase
echo "=== Searching for 'truncated' handling ==="
rg -n --type=php "truncated"
echo ""
echo "=== Searching for getRepositoryTree call sites ==="
rg -n --type=php -A3 "getRepositoryTree"
echo ""
echo "=== Checking the Gitea.php file structure ==="
wc -l src/VCS/Adapter/Git/Gitea.php
echo ""
echo "=== Checking GitHub.php for comparison ==="
rg -n --type=php "getRepositoryTree" src/VCS/Adapter/Git/GitHub.phpRepository: utopia-php/vcs Length of output: 4211 🏁 Script executed: #!/bin/bash
# Get more context on both implementations
echo "=== GitHub.php getRepositoryTree full implementation ==="
sed -n '171,190p' src/VCS/Adapter/Git/GitHub.php
echo ""
echo "=== Gitea.php getRepositoryTree implementation ==="
sed -n '153,163p' src/VCS/Adapter/Git/Gitea.php
echo ""
echo "=== Abstract method definition in Adapter.php ==="
sed -n '215,225p' src/VCS/Adapter.php
echo ""
echo "=== Check if there are any comments or docs about the branch parameter ==="
sed -n '208,220p' src/VCS/Adapter.phpRepository: utopia-php/vcs Length of output: 2643 🏁 Script executed: #!/bin/bash
# Check if GitHub adapter also has truncated issue and look for any API response examples
echo "=== GitHub.php full getRepositoryTree method ==="
sed -n '171,185p' src/VCS/Adapter/Git/GitHub.php
echo ""
echo "=== Check test files for any truncated field references ==="
rg -n "truncated" tests/
echo ""
echo "=== Look for any mocked API responses in tests ==="
rg -n "tree.*\[" tests/VCS/Adapter/GiteaTest.php | head -20
echo ""
echo "=== Check Gitea test setup and mocked responses ==="
sed -n '1,50p' tests/VCS/Adapter/GiteaTest.phpRepository: utopia-php/vcs Length of output: 2127 🏁 Script executed: #!/bin/bash
# Get more details about the test setup and API behavior
echo "=== Full Gitea test method for getRepositoryTree ==="
sed -n '204,235p' tests/VCS/Adapter/GiteaTest.php
echo ""
echo "=== Full GitHub test method for getRepositoryTree ==="
sed -n '187,210p' tests/VCS/Adapter/GitHubTest.php
echo ""
echo "=== Check if there are any comments in GitHub.php about truncated ==="
sed -n '165,180p' src/VCS/Adapter/Git/GitHub.php
echo ""
echo "=== Check if test repos are large enough to trigger truncated ==="
rg -n "test.*repository\|recursive" tests/VCS/Adapter/GiteaTest.php | head -20Repository: utopia-php/vcs Length of output: 3549 🏁 Script executed: #!/bin/bash
# Final verification - check API documentation or comments about what these endpoints accept
echo "=== Check for any README or documentation about API parameters ==="
find . -name "README*" -o -name "*.md" | head -10
echo ""
echo "=== Check if there are any type hints or parameter validation ==="
sed -n '150,165p' src/VCS/Adapter/Git/Gitea.php
echo ""
echo "=== Verify both adapters handle the response identically ==="
echo "GitHub array_column call:"
sed -n '182,182p' src/VCS/Adapter/Git/GitHub.php
echo ""
echo "Gitea array_column call:"
sed -n '163,163p' src/VCS/Adapter/Git/Gitea.php
echo ""
echo "=== Check the actual response structure from real API calls in tests ==="
rg -B5 -A5 "tree\]\['tree'\]" tests/Repository: utopia-php/vcs Length of output: 1110 🏁 Script executed: #!/bin/bash
# Verify the actual API endpoint expectations and response structure
echo "=== Check the abstract method documentation more thoroughly ==="
sed -n '208,226p' src/VCS/Adapter.php
echo ""
echo "=== Search for any Gitea API documentation or comments in code ==="
rg -n "git/trees\|api.*tree" src/VCS/Adapter/Git/Gitea.php
echo ""
echo "=== Check how Gitea resolves 'branch' parameter - check the test that uses 'non-existing-branch' ==="
sed -n '228,234p' tests/VCS/Adapter/GiteaTest.php
echo ""
echo "=== Search for response body structure parsing ==="
rg -n "\['body'\]\['tree'\]" src/VCS/Adapter/Git/Repository: utopia-php/vcs Length of output: 1607 🏁 Script executed: #!/bin/bash
# Final check: verify if both adapters are expected to behave the same way regarding truncated
echo "=== Check if there's any discussion or issue about truncated handling ==="
rg -n "recursive.*tree\|tree.*recursive" src/VCS/Adapter/Git/
echo ""
echo "=== Verify the exact parameter being passed is documented as 'branch' ==="
sed -n '208,216p' src/VCS/Adapter.php
echo ""
echo "=== Check if GitHub tests also use branch names (not SHAs) ==="
grep -n "getRepositoryTree" tests/VCS/Adapter/GitHubTest.php | head -5Repository: utopia-php/vcs Length of output: 1188
When Both Gitea and GitHub adapters have this issue. Consider adding a check: if (!empty($response['body']['truncated'])) {
throw new \RuntimeException("Repository tree response is truncated; too many entries for a single recursive call.");
}Alternatively, document that trees may be incomplete and callers should handle paginated fetching for large repositories. 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matches GitHub adapter behavior. But I think We should handle truncated flag consistently in both need guidance on this @Meldiron There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public function listRepositoryLanguages(string $owner, string $repositoryName): array | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| throw new Exception("Not implemented yet"); | ||||||||||||||||||||||||||||||
| $url = "/repos/{$owner}/{$repositoryName}/languages"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $response = $this->call(self::METHOD_GET, $url, ['Authorization' => "token $this->accessToken"]); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (isset($response['body'])) { | ||||||||||||||||||||||||||||||
| return array_keys($response['body']); | ||||||||||||||||||||||||||||||
|
Comment on lines
+172
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This method returns Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matches the GitHub adapter implementation. If we want to add status code checking, we can do this |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return []; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public function getRepositoryContent(string $owner, string $repositoryName, string $path, string $ref = ''): array | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| throw new Exception("Not implemented yet"); | ||||||||||||||||||||||||||||||
| $url = "/repos/{$owner}/{$repositoryName}/contents/{$path}"; | ||||||||||||||||||||||||||||||
| if (!empty($ref)) { | ||||||||||||||||||||||||||||||
| $url .= "?ref={$ref}"; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $response = $this->call(self::METHOD_GET, $url, ['Authorization' => "token $this->accessToken"]); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (($response['headers']['status-code'] ?? 0) !== 200) { | ||||||||||||||||||||||||||||||
| throw new FileNotFound(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $encoding = $response['body']['encoding'] ?? ''; | ||||||||||||||||||||||||||||||
| $content = ''; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if ($encoding === 'base64') { | ||||||||||||||||||||||||||||||
| $content = base64_decode($response['body']['content'] ?? ''); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| throw new FileNotFound(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+195
to
+199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
PHP's 🛡️ Proposed fix if ($encoding === 'base64') {
- $content = base64_decode($response['body']['content'] ?? '');
+ $decoded = base64_decode($response['body']['content'] ?? '');
+ if ($decoded === false) {
+ throw new FileNotFound();
+ }
+ $content = $decoded;
} else {
throw new FileNotFound();
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub adapter doesn't check this either. Should I add defensive checking here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 342
For consistency across adapters, you can keep the current implementation as-is. The practical risk is minimal since both GitHub and Gitea APIs return well-formed base64 content, so That said, the defensive check would be technically more correct from a type-safety perspective. If you'd prefer to add it, you could:
Either approach is reasonable. Since this is an edge case with trusted API responses, I'd lean toward keeping it consistent with the GitHub adapter (no check) unless you have a specific reason to add extra defensive validation. Your call! 👍 🧬 Code Graph Analysis Results[src/VCS/Adapter/GitHub.php:51-78] public function initializeVariables(string $installationId, string $privateKey, ?string $appId = null, ?string $accessToken = null, ?string $refreshToken = null): void } [src/VCS/Adapter/GitHub.php:375-401] protected function generateAccessToken(string $privateKey, ?string $appId): void } [src/VCS/Adapter/GitHub.php:85-95] public function createRepository(string $owner, string $repositoryName, bool $private): array } |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return [ | ||||||||||||||||||||||||||||||
| 'sha' => $response['body']['sha'] ?? '', | ||||||||||||||||||||||||||||||
| 'size' => $response['body']['size'] ?? 0, | ||||||||||||||||||||||||||||||
| 'content' => $content | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public function listRepositoryContents(string $owner, string $repositoryName, string $path = '', string $ref = ''): array | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| throw new Exception("Not implemented yet"); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| $url = "/repos/{$owner}/{$repositoryName}/contents"; | ||||||||||||||||||||||||||||||
| if (!empty($path)) { | ||||||||||||||||||||||||||||||
| $url .= "/{$path}"; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| if (!empty($ref)) { | ||||||||||||||||||||||||||||||
| $url .= "?ref={$ref}"; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $response = $this->call(self::METHOD_GET, $url, ['Authorization' => "token $this->accessToken"]); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (($response['headers']['status-code'] ?? 0) === 404) { | ||||||||||||||||||||||||||||||
| return []; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $items = []; | ||||||||||||||||||||||||||||||
| if (!empty($response['body'][0])) { | ||||||||||||||||||||||||||||||
| $items = $response['body']; | ||||||||||||||||||||||||||||||
| } elseif (!empty($response['body'])) { | ||||||||||||||||||||||||||||||
| $items = [$response['body']]; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $contents = []; | ||||||||||||||||||||||||||||||
| foreach ($items as $item) { | ||||||||||||||||||||||||||||||
| $type = $item['type'] ?? 'file'; | ||||||||||||||||||||||||||||||
| $contents[] = [ | ||||||||||||||||||||||||||||||
| 'name' => $item['name'] ?? '', | ||||||||||||||||||||||||||||||
| 'size' => $item['size'] ?? 0, | ||||||||||||||||||||||||||||||
| 'type' => $type === 'file' ? self::CONTENTS_FILE : self::CONTENTS_DIRECTORY | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return $contents; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| } | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,30 @@ private function setupGitea(): void | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Helper method to create a file in a repository | ||||||||||||||||||
| */ | ||||||||||||||||||
| private function createFile(string $owner, string $repo, string $filepath, string $content, string $message = 'Add file'): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $giteaUrl = System::getEnv('TESTS_GITEA_URL', 'http://gitea:3000') ?? ''; | ||||||||||||||||||
| $url = "{$giteaUrl}/api/v1/repos/{$owner}/{$repo}/contents/{$filepath}"; | ||||||||||||||||||
|
|
||||||||||||||||||
| $ch = curl_init($url); | ||||||||||||||||||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||||||||||||||||||
| curl_setopt($ch, CURLOPT_POST, true); | ||||||||||||||||||
| curl_setopt($ch, CURLOPT_HTTPHEADER, [ | ||||||||||||||||||
| 'Authorization: token ' . self::$accessToken, | ||||||||||||||||||
| 'Content-Type: application/json' | ||||||||||||||||||
| ]); | ||||||||||||||||||
| curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ | ||||||||||||||||||
| 'content' => base64_encode($content), | ||||||||||||||||||
| 'message' => $message | ||||||||||||||||||
| ])); | ||||||||||||||||||
|
|
||||||||||||||||||
| curl_exec($ch); | ||||||||||||||||||
|
||||||||||||||||||
| curl_close($ch); | ||||||||||||||||||
| } | ||||||||||||||||||
jaysomani marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
|
||||||||||||||||||
| public function testCreateRepository(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $owner = self::$owner; | ||||||||||||||||||
|
|
@@ -168,17 +192,159 @@ public function testGetRepositoryWithNonExistingOwner(): void | |||||||||||||||||
|
|
||||||||||||||||||
| public function testGetRepositoryTree(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $this->markTestSkipped('Will be implemented in follow-up PR'); | ||||||||||||||||||
| $repositoryName = 'test-get-repository-tree-' . \uniqid(); | ||||||||||||||||||
| $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Create files in repo | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'README.md', '# Test Repo'); | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'src/main.php', '<?php echo "hello";'); | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'src/lib.php', '<?php // library'); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Test non-recursive (should only show root level) | ||||||||||||||||||
| $tree = $this->vcsAdapter->getRepositoryTree(self::$owner, $repositoryName, 'main', false); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->assertIsArray($tree); | ||||||||||||||||||
| $this->assertContains('README.md', $tree); | ||||||||||||||||||
| $this->assertContains('src', $tree); | ||||||||||||||||||
| $this->assertCount(2, $tree); // Only README.md and src folder at root | ||||||||||||||||||
|
|
||||||||||||||||||
| // Test recursive (should show all files including nested) | ||||||||||||||||||
| $treeRecursive = $this->vcsAdapter->getRepositoryTree(self::$owner, $repositoryName, 'main', true); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->assertIsArray($treeRecursive); | ||||||||||||||||||
| $this->assertContains('README.md', $treeRecursive); | ||||||||||||||||||
| $this->assertContains('src', $treeRecursive); | ||||||||||||||||||
| $this->assertContains('src/main.php', $treeRecursive); | ||||||||||||||||||
| $this->assertContains('src/lib.php', $treeRecursive); | ||||||||||||||||||
| $this->assertGreaterThanOrEqual(4, count($treeRecursive)); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function testGetRepositoryTreeWithInvalidBranch(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $repositoryName = 'test-get-repository-tree-invalid-' . \uniqid(); | ||||||||||||||||||
| $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'README.md', '# Test'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $tree = $this->vcsAdapter->getRepositoryTree(self::$owner, $repositoryName, 'non-existing-branch', false); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->assertIsArray($tree); | ||||||||||||||||||
| $this->assertEmpty($tree); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function testGetRepositoryContent(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $this->markTestSkipped('Will be implemented in follow-up PR'); | ||||||||||||||||||
| $repositoryName = 'test-get-repository-content-' . \uniqid(); | ||||||||||||||||||
| $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); | ||||||||||||||||||
|
|
||||||||||||||||||
| $fileContent = '# Hello World'; | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'README.md', $fileContent); | ||||||||||||||||||
|
|
||||||||||||||||||
| $result = $this->vcsAdapter->getRepositoryContent(self::$owner, $repositoryName, 'README.md'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->assertIsArray($result); | ||||||||||||||||||
| $this->assertArrayHasKey('content', $result); | ||||||||||||||||||
| $this->assertArrayHasKey('sha', $result); | ||||||||||||||||||
| $this->assertArrayHasKey('size', $result); | ||||||||||||||||||
| $this->assertSame($fileContent, $result['content']); | ||||||||||||||||||
| $this->assertIsString($result['sha']); | ||||||||||||||||||
| $this->assertGreaterThan(0, $result['size']); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function testGetRepositoryContentWithRef(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $repositoryName = 'test-get-repository-content-ref-' . \uniqid(); | ||||||||||||||||||
| $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'test.txt', 'main branch content'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $result = $this->vcsAdapter->getRepositoryContent(self::$owner, $repositoryName, 'test.txt', 'main'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->assertIsArray($result); | ||||||||||||||||||
| $this->assertSame('main branch content', $result['content']); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public function testGetRepositoryContentFileNotFound(): void | ||||||||||||||||||
| { | ||||||||||||||||||
| $repositoryName = 'test-get-repository-content-not-found-' . \uniqid(); | ||||||||||||||||||
| $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); | ||||||||||||||||||
| $this->createFile(self::$owner, $repositoryName, 'README.md', '# Test'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->expectException(\Utopia\VCS\Exception\FileNotFound::class); | ||||||||||||||||||
| $this->vcsAdapter->getRepositoryContent(self::$owner, $repositoryName, 'non-existing.txt'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | ||||||||||||||||||
|
Comment on lines
+281
to
+283
|
||||||||||||||||||
| $this->vcsAdapter->getRepositoryContent(self::$owner, $repositoryName, 'non-existing.txt'); | |
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | |
| try { | |
| $this->vcsAdapter->getRepositoryContent(self::$owner, $repositoryName, 'non-existing.txt'); | |
| } finally { | |
| $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a trailing whitespace at the end of this line. This is inconsistent with code formatting standards.