diff --git a/shared/utils/self_upgrade.py b/shared/utils/self_upgrade.py
index 9c3e95d3..55e67563 100644
--- a/shared/utils/self_upgrade.py
+++ b/shared/utils/self_upgrade.py
@@ -34,7 +34,9 @@ def get_current_branch(repo: Repo) -> Head:
def get_github_repo(repo: Repo) -> str:
remote_url = repo.remote().url
remote_url += "" if remote_url.endswith(".git") else ".git"
- return re.search(r"(?<=github.com/).+?(?=\.git)", remote_url).group()
+ if github_match := re.search(r"(?<=github.com[/:]).+?(?=\.git)", remote_url):
+ return github_match.group()
+ raise RuntimeError("无法获取 GitHub 仓库地址,请检查当前目录是否为克隆自 GitHub 的 Git 仓库")
async def get_remote_commit_sha(repo: str, branch: str) -> str:
@@ -113,9 +115,7 @@ async def check_update():
message = message.replace("<", r"\<").splitlines()[0]
output.append(f"{sha} {message}")
history = "\n".join(["", *output, ""])
- logger.opt(colors=True).warning(
- f"发现新版本\n{history}"
- )
+ logger.opt(colors=True).warning(f"发现新版本\n{history}")
if not config.auto_upgrade:
return
logger.opt(colors=True).info("正在自动更新")