From 965d9162a05032dc4b63b4ca1f722740843975f9 Mon Sep 17 00:00:00 2001 From: "sayurinana(vm)" Date: Wed, 17 Dec 2025 05:29:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(flow):=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E6=94=AF=E5=88=87=E6=8D=A2=E6=97=B6=20lock=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 BranchManager 中添加 _cleanup_lock_file 方法, 在 _merge_normal 和 _merge_with_temp_branch 调用 git checkout 前 先清理可能存在的 lock 文件,避免分支切换失败。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 1 - aide-program/aide/flow/branch.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 89ad554..fe7bfe5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ anthropic-agent-skills/ __pycache__/ .venv/ test-cache/ - diff --git a/aide-program/aide/flow/branch.py b/aide-program/aide/flow/branch.py index bc1175d..e3e52dd 100644 --- a/aide-program/aide/flow/branch.py +++ b/aide-program/aide/flow/branch.py @@ -92,9 +92,18 @@ class BranchManager: self.aide_dir = root / ".aide" self.branches_json = self.aide_dir / "branches.json" self.branches_md = self.aide_dir / "branches.md" + self.lock_path = self.aide_dir / "flow-status.lock" self._data: BranchesData | None = None self._current_branch_info: BranchInfo | None = None + def _cleanup_lock_file(self) -> None: + """清理 lock 文件,避免分支切换时的冲突""" + try: + if self.lock_path.exists(): + self.lock_path.unlink() + except OSError: + pass + def load_branches(self) -> BranchesData: """加载分支概况""" if self._data is not None: @@ -314,6 +323,9 @@ class BranchManager: source_branch = branch_info.source_branch start_commit = branch_info.start_commit + # 切换分支前清理 lock 文件,避免冲突 + self._cleanup_lock_file() + # 切回源分支 self.git.checkout(source_branch) @@ -343,6 +355,9 @@ class BranchManager: task_branch = branch_info.branch_name temp_branch = f"{task_branch}-merge" + # 切换分支前清理 lock 文件,避免冲突 + self._cleanup_lock_file() + # 从起始提交检出临时分支 self.git.checkout_new_branch(temp_branch, start_commit)