mirror of
https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge.git
synced 2026-08-29 16:40:32 +08:00
refactor(utils/crawl_github_files): deciding default branch
Previously the default branch name was considered to be "main", which was wrong. To fix this, dont put the ref param to query and let Github decide default branch.
This commit is contained in:
@@ -202,7 +202,9 @@ def crawl_github_files(
|
||||
part_index = 5 if '/' in ref else 4
|
||||
specific_path = join_parts(part_index) if part_index < len(path_parts) else ""
|
||||
else:
|
||||
ref = "main" # Default branch
|
||||
# Dont put the ref param to quiery
|
||||
# and let Github decide default branch
|
||||
ref = None
|
||||
specific_path = ""
|
||||
|
||||
# Dictionary to store path -> content mapping
|
||||
@@ -212,7 +214,7 @@ def crawl_github_files(
|
||||
def fetch_contents(path):
|
||||
"""Fetch contents of the repository at a specific path and commit"""
|
||||
url = f"https://api.github.com/repos/{owner}/{repo}/contents/{path}"
|
||||
params = {"ref": ref}
|
||||
params = {"ref": ref} if ref != None else {}
|
||||
|
||||
response = requests.get(url, headers=headers, params=params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user