Peach: Local-first video metadata scraper and media manager.
fix(release): 按列读 porcelain 前不再对整段输出 strip
longmeidao3e213a24e3ed
diff --git a/scripts/release_tag.py b/scripts/release_tag.pyindex e426c3ac1..8a26a51ff 100644--- a/scripts/release_tag.py+++ b/scripts/release_tag.py@@ -36,9 +36,12 @@ TEST_TIMEOUT = 1800.0TEST_POLL = 30.0-def command(*args: str) -> str:- return subprocess.run(args, cwd=ROOT, check=True, capture_output=True,- text=True, encoding="utf-8").stdout.strip()+def command(*args: str, strip: bool = True) -> str:+ """`strip=False` 给首列本身就是空格的输出用:`git status --porcelain` 的第一行是+ ` M CHANGELOG.md`,整体 strip 会连状态列的空格一起吃掉,按列取路径就少一个字。"""+ output = subprocess.run(args, cwd=ROOT, check=True, capture_output=True,+ text=True, encoding="utf-8").stdout+ return output.strip() if strip else outputdef api(repo: str, endpoint: str):@@ -142,7 +145,7 @@ def _require_master() -> None:def _pending_files() -> list[str]:"""工作区里有改动的文件名,按 `git status --porcelain` 的第三列取。"""return sorted(line[3:].strip().strip('"')- for line in command("git", "status", "--porcelain").splitlines()+ for line in command("git", "status", "--porcelain", strip=False).splitlines()if line.strip())diff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex 32e7fa13f..018479fd1 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -2268,7 +2268,7 @@ class ReleaseTagTests(unittest.TestCase):def _shell(self, changes=None):answers = {**self.CLEAN, **(changes or {})}return mock.patch.object(self.release, "command",- side_effect=lambda *args: answers.get(args, ""))+ side_effect=lambda *args, **_: answers.get(args, ""))def test_plan_refuses_dirty_checkout_wrong_branch_and_existing_tags(self):for changes, refs in (({("git", "status", "--porcelain"): " M file"}, []),@@ -2352,7 +2352,7 @@ class ShipTests(unittest.TestCase):def _shell(self, changes=None):answers = {**self.SHELL, **(changes or {})}return mock.patch.object(self.release, "command",- side_effect=lambda *args: answers.get(args, ""))+ side_effect=lambda *args, **_: answers.get(args, ""))def _api(self, *, tags=(), remote="old", runs=(SUCCESS,)):def answer(_repo, endpoint):@@ -2385,6 +2385,16 @@ class ShipTests(unittest.TestCase):("v0.8.0", True, True))self.assertEqual(self._writes(command), [])+ def test_pending_files_keep_the_status_column_of_the_first_line(self):+ """`git status --porcelain` 首行以空格开头;按列取路径前不能对整段输出 strip。++ 2026-09-08 定版时两份文件都在,发布却被拒:第一行被读成 `HANGELOG.md`。"""+ porcelain = " M CHANGELOG.md\n M src/peach/__init__.py\n"+ with mock.patch.object(self.release.subprocess, "run",+ return_value=mock.Mock(stdout=porcelain)):+ self.assertEqual(self.release._pending_files(),+ ["CHANGELOG.md", "src/peach/__init__.py"])+def test_unrelated_changes_are_never_carried_into_the_release_commit(self):"""标签指向发布提交,夹带什么就等于发出去什么。"""dirty = {("git", "status", "--porcelain"):