From: Codebuddy Date: Wed, 30 Sep 2026 05:08:01 +0000 (+0800) Subject: feat: 任务清单自动 commit 后同步 push 到 github(使用新 token) X-Git-Url: http://acesimba.cloud/gitweb/?a=commitdiff_plain;h=4927e292341e86a144cda52fa4cb8221d1496a72;p=codebuddy-web.git feat: 任务清单自动 commit 后同步 push 到 github(使用新 token) --- diff --git a/backend/app.py b/backend/app.py index eeb6cdd..f001f47 100644 --- a/backend/app.py +++ b/backend/app.py @@ -239,7 +239,7 @@ def _tasks_git_rel() -> str: def _git_commit_tasks() -> None: - """保存任务清单后自动提交到 git。失败仅告警,不影响接口正常返回。""" + """保存任务清单后自动提交到 git,并同步推送到 github。失败仅告警,不影响接口正常返回。""" try: with _GIT_LOCK: subprocess.run(["git", "add", "--", _tasks_git_rel()], cwd=_REPO_ROOT, @@ -249,6 +249,13 @@ def _git_commit_tasks() -> None: # 无实际变更时 git commit 返回非 0,忽略 if r.returncode == 0: logger.info("任务清单已自动 git commit") + # 同步推送到 github(令牌写在 remote URL 中) + p = subprocess.run(["git", "push", "github", "master"], + cwd=_REPO_ROOT, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + if p.returncode == 0: + logger.info("任务清单已自动 git push 到 github") + else: + logger.warning("任务清单 git push 到 github 失败(本地 commit 已保留)") except Exception as e: logger.warning(f"任务清单 git commit 失败(文件已保存): {e}")