Skip to content

Commit

Permalink
Merge pull request #225 from leeeizhang/lei/fix-github-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyz0918 authored Sep 28, 2024
2 parents 6f378d6 + a5e556a commit cac9cb7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mle/integration/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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']

Expand Down

0 comments on commit cac9cb7

Please sign in to comment.