Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nonebot-plugin-mimo-console"
version = "0.1.6"
version = "0.1.7"
description = "A premium WebUI management console for NoneBot2"
readme = "README.md"
requires-python = ">=3.10"
Expand Down Expand Up @@ -54,7 +54,7 @@ requires = ["uv_build>=0.10.0,<0.12.0"]
build-backend = "uv_build"

[tool.bumpversion]
current_version = "0.1.6"
current_version = "0.1.7"
commit = true
message = "chore: 发布 v{new_version}"
tag = true
Expand Down
9 changes: 5 additions & 4 deletions src/nonebot_plugin_mimo_console/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,8 @@ async def store_plugin_readme(
if not homepage:
return {"ok": False, "content": "", "detail": "该插件未提供主页链接"}
import re as _re
match = _re.match(
r"https?://github\.com/([^/]+)/([^/?#]+)", homepage
)

match = _re.match(r"https?://github\.com/([^/]+)/([^/?#]+)", homepage)
if not match:
return {"ok": False, "content": "", "detail": "主页不是 GitHub 仓库,无法获取 README"}
owner, repo = match.group(1), match.group(2).removesuffix(".git")
Expand All @@ -282,7 +281,9 @@ async def store_plugin_readme(
if proxy and not is_mirror_repo(proxy):
raw_url = f"{proxy}https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{filename}"
else:
raw_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{filename}"
raw_url = (
f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{filename}"
)
try:
resp = await client.get(
raw_url,
Expand Down
8 changes: 7 additions & 1 deletion src/nonebot_plugin_mimo_console/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ def build_self_update_command(
if not SAFE_NAME_RE.fullmatch(project_name):
raise ValueError("插件包名不合法")
uv = uv_executable if uv_executable is not None else _find_uv_executable()
if uv and (project_root / "pyproject.toml").is_file():
# gh-proxy 风格前缀会把代理前缀拼在 GitHub URL 之前,形成含多个 "://" 的套娃 URL
# (如 https://gh-proxy.com/https://github.com/...)。uv 解析
# "git+<套娃URL>@<ref>" 时其 URL 解析器会 panic(AmbiguousAuthority),
# 而 pip 直接交给 git clone,对套娃 URL 鲁棒。因此前缀代理走 pip;
# 干净 URL(直连或 CNB 镜像仓库地址)仍走 uv。
is_prefix_proxy_url = git_url.count("://") > 1
if uv and (project_root / "pyproject.toml").is_file() and not is_prefix_proxy_url:
return [
uv,
"add",
Expand Down
20 changes: 20 additions & 0 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ def test_build_self_update_command_falls_back_to_pip(self) -> None:
command[-1], "git+https://github.com/MimoKit/nonebot-plugin-mimo-console.git"
)

def test_build_self_update_command_uses_pip_for_prefix_proxy(self) -> None:
# gh-proxy 风格前缀会把代理前缀拼在 GitHub URL 前,形成含多个 "://" 的套娃
# URL(如 https://gh-proxy.com/https://github.com/...)。即便项目用 uv 管理,
# 此种 URL 也必须走 pip——uv 解析 "git+<套娃URL>@<ref>" 会让解析器 panic。
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
(root / "pyproject.toml").write_text("[project]\nname='bot'\n", encoding="utf-8")
command = store.build_self_update_command(
root,
"nonebot-plugin-mimo-console",
"https://gh-proxy.com/https://github.com/MimoKit/nonebot-plugin-mimo-console.git",
uv_executable="/usr/bin/uv",
)
self.assertNotEqual(command[0], "/usr/bin/uv")
self.assertEqual(command[:4], [sys.executable, "-m", "pip", "install"])
self.assertEqual(
command[-1],
"git+https://gh-proxy.com/https://github.com/MimoKit/nonebot-plugin-mimo-console.git",
)

def test_registry_item_validation(self) -> None:
valid = {
"module_name": "nonebot_plugin_status",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading