GhApi.get_repo_contents
method
#190
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds couple of utility methods to get repo file contents, which can be useful for dynamically creating the LLM context. Tested these changes locally with my editable builld.
get_repo_files(self:GhApi, owner, repo, branch="main", inc=None, exc=None)
:This method returns all the repo files recursively using
git.get_tree
as recommended in the official GH api docs and allows filtering by passinginc
:included andexc
:excluded Unix-style wildcards using fnmatch. If a file matches one of the patterns in both included and excluded lists, then*
expression is prioritized, if both have*
expression than the longer expression is prioritized. This is useful for some common filtering cases, for example "Exclude all .md files expect for README.md", or "Include all .py files except for tests".get_file_content(self:GhApi, path, owner, repo, branch="main")
:Gets file content of given file and also decodes the file content.
get_repo_contents(self:GhApi, owner, repo, **kwargs)
:This uses
GhApi.get_repo_files
+ parallelGhApi.get_file_content
to get all repo contents.More examples and explanations can be found in the core nb.