fix(flow): 修复分支切换时 lock 文件冲突问题
在 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 <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,4 +2,3 @@ anthropic-agent-skills/
|
||||
__pycache__/
|
||||
.venv/
|
||||
test-cache/
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user