mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-04 03:10:01 +08:00
✨ feat(repo_utils): Add branch parameter to get_github_file_content method in RepoFileManager
This commit is contained in:
@@ -41,16 +41,24 @@ class RepoFileManager:
|
|||||||
|
|
||||||
@overload
|
@overload
|
||||||
async def get_github_file_content(
|
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: ...
|
) -> str: ...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
async def get_github_file_content(
|
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]]: ...
|
) -> list[tuple[str, str]]: ...
|
||||||
|
|
||||||
async def get_github_file_content(
|
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]]:
|
) -> str | list[tuple[str, str]]:
|
||||||
"""
|
"""
|
||||||
获取GitHub仓库文件内容
|
获取GitHub仓库文件内容
|
||||||
@@ -69,6 +77,7 @@ class RepoFileManager:
|
|||||||
if is_str_input:
|
if is_str_input:
|
||||||
file_path = [file_path]
|
file_path = [file_path]
|
||||||
repo_info = GithubUtils.parse_github_url(url)
|
repo_info = GithubUtils.parse_github_url(url)
|
||||||
|
repo_info.branch = branch
|
||||||
if await repo_info.update_repo_commit():
|
if await repo_info.update_repo_commit():
|
||||||
logger.info(f"获取最新提交: {repo_info.branch}", LOG_COMMAND)
|
logger.info(f"获取最新提交: {repo_info.branch}", LOG_COMMAND)
|
||||||
else:
|
else:
|
||||||
@@ -225,13 +234,13 @@ class RepoFileManager:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return await self.get_github_file_content(
|
return await self.get_github_file_content(
|
||||||
repo_url, file_path, ignore_error
|
repo_url, file_path, branch, ignore_error
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if repo_type == RepoType.GITHUB:
|
if repo_type == RepoType.GITHUB:
|
||||||
return await self.get_github_file_content(
|
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:
|
elif repo_type == RepoType.ALIYUN:
|
||||||
|
|||||||
Reference in New Issue
Block a user