-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add endpoint to fetch repo tree #17
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 |
---|---|---|
|
@@ -150,6 +150,28 @@ public function getRepositoryName(string $repositoryId): string | |
return $response['body']['name']; | ||
} | ||
|
||
/** | ||
* Get repository tree | ||
* | ||
* @param string $owner Owner name of the repository | ||
* @param string $repositoryName Name of the GitHub repository | ||
* @param string $branch Name of the branch | ||
* @param bool $recursive Whether to fetch the tree recursively | ||
* @return array<string> List of files in the repository | ||
*/ | ||
public function getRepositoryTree(string $owner, string $repositoryName, string $branch, bool $recursive = false): array | ||
{ | ||
// if recursive is true, add optional query param to url | ||
$url = "/repos/$owner/$repositoryName/git/trees/$branch" . ($recursive ? '?recursive=1' : ''); | ||
$response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"]); | ||
|
||
if ($response['headers']['status-code'] == 404) { | ||
return []; | ||
} | ||
|
||
return array_column($response['body']['tree'], 'path'); | ||
} | ||
Comment on lines
+162
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. Why do we want a new method? Can we not use the existing listRepositoryContents method? 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. As discussed, we can add it to the vcs library and may or may not use it in appwrite |
||
|
||
/** | ||
* Get repository languages | ||
* | ||
|
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.
Lets check if we can specify depth limit