From 65b125dd07017ce84f3bb347ecce0cbebd4dedcc Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Thu, 26 Mar 2026 17:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(repo=5Futils):=20Add=20branch?= =?UTF-8?q?=20parameter=20to=20get=5Fgithub=5Ffile=5Fcontent=20method=20in?= =?UTF-8?q?=20RepoFileManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/utils/repo_utils/file_manager.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/zhenxun/utils/repo_utils/file_manager.py b/zhenxun/utils/repo_utils/file_manager.py index c4c3021a..18693bb3 100644 --- a/zhenxun/utils/repo_utils/file_manager.py +++ b/zhenxun/utils/repo_utils/file_manager.py @@ -41,16 +41,24 @@ class RepoFileManager: @overload async def get_github_file_content( - self, url: str, file_path: str, ignore_error: bool = False + self, url: str, file_path: str, branch: str = "main", ignore_error: bool = False ) -> str: ... @overload async def get_github_file_content( - self, url: str, file_path: list[str], ignore_error: bool = False + self, + url: str, + file_path: list[str], + branch: str = "main", + ignore_error: bool = False, ) -> list[tuple[str, str]]: ... async def get_github_file_content( - self, url: str, file_path: str | list[str], ignore_error: bool = False + self, + url: str, + file_path: str | list[str], + branch: str = "main", + ignore_error: bool = False, ) -> str | list[tuple[str, str]]: """ 获取GitHub仓库文件内容 @@ -69,6 +77,7 @@ class RepoFileManager: if is_str_input: file_path = [file_path] repo_info = GithubUtils.parse_github_url(url) + repo_info.branch = branch if await repo_info.update_repo_commit(): logger.info(f"获取最新提交: {repo_info.branch}", LOG_COMMAND) else: @@ -225,13 +234,13 @@ class RepoFileManager: ) except Exception: return await self.get_github_file_content( - repo_url, file_path, ignore_error + repo_url, file_path, branch, ignore_error ) try: if repo_type == RepoType.GITHUB: return await self.get_github_file_content( - repo_url, file_path, ignore_error + repo_url, file_path, branch, ignore_error ) elif repo_type == RepoType.ALIYUN: