]> acesimba.cloud Git - codebuddy-web.git/commitdiff
feat: 任务清单自动 commit 后同步 push 到 github(使用新 token)
authorCodebuddy <codebuddy@localhost>
Wed, 30 Sep 2026 05:08:01 +0000 (13:08 +0800)
committerCodebuddy <codebuddy@localhost>
Wed, 30 Sep 2026 05:08:01 +0000 (13:08 +0800)
backend/app.py

index eeb6cdd426630b7e97ed8a7e0454677a728cc675..f001f475ecda62415c8dcfc942586a88219e8256 100644 (file)
@@ -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}")