pr: commit worktree changes before push; fix merge/pr order docs

POST /tasks/{id}/pr used to push the branch as-is, so uncommitted
worktree changes never reached the PR (empty diff). Now, after all
skip checks pass, the endpoint commits the worktree on host/<task>
(guarded: refuses when the worktree is on another branch), cleans
__pycache__/*.pyc like host.py merge does, and falls back to the
cloud identity when no git identity is configured. Nothing-to-commit
proceeds. Docs corrected: PR comes after status-merge and before
any local git merge (which deletes branch+worktree).
This commit is contained in:
host committed 2026-10-26 15:20:02 +08:00
1 parent b984171f27
commit 0b96b2929c
5 files changed
+263 -10

No files matched your search

+6 -4
View File
@@ -1279,10 +1279,12 @@ class CloudControlPlaneHandler(BaseHTTPRequestHandler):
def _merge_task(self, user_id, task_id):
"""把云端任务标记为已合并:只补状态,不执行合并本身。
合并本身仍由 host.py merge(本地或 Docker 容器内)执行,
成功后再调本接口同步云端状态——两者分离是故意的:合并
是要人看 diff 才点的操作,云端不该在任务 completed 时
自动把主分支改了。规则:任务必须存在(404)、调用方
本接口不做 git 合并。自动 PR 的正确顺序是:任务
completed -> 调本接口改状态 -> 调 POST /tasks/{id}/pr
推分支建 PR -> 再在 GitHub 上合 PR 或本地 host.py merge。
本地 host.py merge 成功后会删分支和 worktree,此后调
PR 会跳过 no_worktree,所以 PR 必须在本地 git merge
之前做,而不是之后。规则:任务必须存在(404)、调用方
必须是项目 maintainer 以上(approve_merge,403)、任务
必须是 completed(其它状态一律 409,含已 merged 的重复
调用,避免二次合并混淆)。成功后写审计 merge_task。