Skip to content
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

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Conversation

vermakhushboo
Copy link
Member

Add endpoint to fetch repo tree to enable UI for root directory selection

Comment on lines +162 to +173
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');
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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

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' : '');
Copy link
Contributor

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

@christyjacob4 christyjacob4 merged commit 5ed3f98 into main Jun 7, 2024
3 checks passed
@christyjacob4 christyjacob4 deleted the feat-add-get-tree-endpoint branch June 7, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants