-
Notifications
You must be signed in to change notification settings - Fork 70
GhApi.get_repo_contents method
#190
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
Conversation
|
@KeremTurgutlu sorry I forgot to look at this! It looks great :D My only request is that you cut back on the output so that the docs are more concise. We really like things to be concise! Having more stuff for the user to read is a burden that we should only require where the upside outweighs the downside. So have a look at each line of code and each line of output and think about whether reaches that bar. If it doesn't, cut it back until it does. |
|
@KeremTurgutlu just bumping this so we don't lose it ^^^ |
|
@jph00 thanks for the reminder! I wonder if this is still needed given that we already have
|
|
Repo2ctx requires a full clone, so your way (particularly the file listing) seems like a win to me! :) |
76b58c9 to
6afd23e
Compare
|
@jph00 I've made the following changes to make the code simpler and cleaner. Not sure why all the cell ids changed after Logic:
Tests:
Documentation:
Minor Change
|
|
Thanks @KeremTurgutlu ! :) |
|
Oh figured out the ids issue - we had |

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_treeas 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_contentto get all repo contents.More examples and explanations can be found in the core nb.