From 03555caa87b669de249ea94e64cc431397429895 Mon Sep 17 00:00:00 2001 From: siaeyy Date: Wed, 23 Apr 2025 12:21:36 +0300 Subject: [PATCH] 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. --- utils/crawl_github_files.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/crawl_github_files.py b/utils/crawl_github_files.py index 37f8177..660a493 100644 --- a/utils/crawl_github_files.py +++ b/utils/crawl_github_files.py @@ -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)