From a5e556a256eca671acb64d08b81650d599a9c27d Mon Sep 17 00:00:00 2001 From: "leizhang.real@gmail.com" Date: Sat, 28 Sep 2024 05:30:04 -0500 Subject: [PATCH] fix github branch error --- mle/integration/github.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mle/integration/github.py b/mle/integration/github.py index c7d3d6a..f546d11 100644 --- a/mle/integration/github.py +++ b/mle/integration/github.py @@ -440,11 +440,11 @@ def get_releases(self, limit=100): for release in self._make_request("releases", params={"per_page": limit}) ] - def get_structure(self, path='', branch='main', include_invisible=False): + def get_structure(self, path='', branch=None, include_invisible=False): """ Scan and return the file structure and file names of the GitHub repository as a list of paths. :param path: The path to start scanning from (default is root) - :param branch: The branch to scan (default is 'main') + :param branch: The branch to scan (if None, the repository's default branch will be used) :param include_invisible: Whether to include invisible files/folders (starting with .) (default is False) :return: A list of file paths in the repository """ @@ -463,6 +463,9 @@ def traverse_tree(tree_sha, current_path): return paths # Get the SHA of the latest commit on the specified branch + if branch is None: + branch = self._make_request().get("default_branch", "main") + branch_data = self._make_request(f'branches/{branch}') root_tree_sha = branch_data['commit']['commit']['tree']['sha']