From 70350aa39fb944b539779144a200d4934bb7eb22 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 16 Apr 2026 19:36:55 +0800 Subject: [PATCH] fix local update dirty check --- .gitignore | 1 + scripts/local_setup.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9c103205..77746a82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.DS_Store *.c *.so *.pyd diff --git a/scripts/local_setup.py b/scripts/local_setup.py index 4c7946a1..9e0e0f93 100644 --- a/scripts/local_setup.py +++ b/scripts/local_setup.py @@ -1425,9 +1425,24 @@ def _git_output(*args: str) -> str: def _ensure_git_clean() -> None: - status = _git_output("status", "--porcelain") - if status.strip(): - raise RuntimeError("检测到当前仓库有未提交改动,请先提交或清理后再执行更新。") + status = _git_output("status", "--porcelain", "--untracked-files=no") + if not status.strip(): + return + + changed_files: list[str] = [] + for line in status.splitlines(): + if len(line) < 4: + continue + changed_files.append(line[3:].strip()) + + detail = "" + if changed_files: + preview = "、".join(changed_files[:5]) + if len(changed_files) > 5: + preview += " 等" + detail = f":{preview}" + + raise RuntimeError(f"检测到当前仓库有未提交的源码改动{detail},请先提交或清理后再执行更新。") def _update_backend_ref(ref: str) -> str: