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

[MRG] fix github integration to fetch master branch #225

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading