iryx commited on
Commit
97db5ca
·
1 Parent(s): 17dc889

fix: log sync errors instead of swallowing them

Browse files
Files changed (1) hide show
  1. app.py +31 -7
app.py CHANGED
@@ -78,17 +78,41 @@ def is_allowed(args):
78
  def _try_sync_repo(owner: str, repo: str):
79
  path = repo_path(owner, repo)
80
  if not os.path.isdir(path) or not os.path.exists(os.path.join(path, ".git")):
 
 
81
  return
82
  try:
83
  branch = subprocess.run(["git", "branch", "--show-current"], cwd=path, capture_output=True, text=True).stdout.strip() or "main"
84
- subprocess.run(["git", "pull", "--rebase", "origin", branch], cwd=path, capture_output=True, text=True, timeout=30)
85
- status = subprocess.run(["git", "status", "--short"], cwd=path, capture_output=True, text=True).stdout.strip()
 
 
 
 
 
 
 
86
  if status:
87
- subprocess.run(["git", "add", "-A"], cwd=path, capture_output=True)
88
- subprocess.run(["git", "commit", "-m", "codexa: auto-sync"], cwd=path, capture_output=True)
89
- subprocess.run(["git", "push", "origin", f"HEAD:{branch}"], cwd=path, capture_output=True, text=True, timeout=30)
90
- except Exception:
91
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
 
94
  def spawn(command: str, owner: str = "", repo: str = ""):
 
78
  def _try_sync_repo(owner: str, repo: str):
79
  path = repo_path(owner, repo)
80
  if not os.path.isdir(path) or not os.path.exists(os.path.join(path, ".git")):
81
+ print(f">>> _try_sync_repo skip: no repo at {path}", file=sys.stderr)
82
+ sys.stderr.flush()
83
  return
84
  try:
85
  branch = subprocess.run(["git", "branch", "--show-current"], cwd=path, capture_output=True, text=True).stdout.strip() or "main"
86
+ print(f">>> _try_sync_repo pull {owner}/{repo} branch={branch}", file=sys.stderr)
87
+ sys.stderr.flush()
88
+ pull = subprocess.run(["git", "pull", "--rebase", "origin", branch], cwd=path, capture_output=True, text=True, timeout=30)
89
+ if pull.returncode != 0:
90
+ print(f">>> _try_sync_repo pull failed: rc={pull.returncode} {pull.stderr.strip()}", file=sys.stderr)
91
+ sys.stderr.flush()
92
+ status = subprocess.run(["git", "status", "--short", "--branch"], cwd=path, capture_output=True, text=True).stdout.strip()
93
+ print(f">>> _try_sync_repo status: {status!r}", file=sys.stderr)
94
+ sys.stderr.flush()
95
  if status:
96
+ add = subprocess.run(["git", "add", "-A"], cwd=path, capture_output=True, text=True)
97
+ if add.returncode != 0:
98
+ print(f">>> _try_sync_repo add failed: {add.stderr.strip()}", file=sys.stderr)
99
+ commit = subprocess.run(["git", "commit", "-m", "codexa: auto-sync"], cwd=path, capture_output=True, text=True)
100
+ if commit.returncode != 0:
101
+ print(f">>> _try_sync_repo commit failed: rc={commit.returncode} {commit.stderr.strip()}", file=sys.stderr)
102
+ sys.stderr.flush()
103
+ else:
104
+ print(f">>> _try_sync_repo committed: {commit.stdout.strip()}", file=sys.stderr)
105
+ sys.stderr.flush()
106
+ push = subprocess.run(["git", "push", "origin", f"HEAD:{branch}"], cwd=path, capture_output=True, text=True, timeout=30)
107
+ if push.returncode != 0:
108
+ print(f">>> _try_sync_repo push failed: rc={push.returncode} {push.stderr.strip()}", file=sys.stderr)
109
+ sys.stderr.flush()
110
+ else:
111
+ print(f">>> _try_sync_repo pushed to {branch}", file=sys.stderr)
112
+ sys.stderr.flush()
113
+ except Exception as e:
114
+ print(f">>> _try_sync_repo exception: {e}", file=sys.stderr)
115
+ sys.stderr.flush()
116
 
117
 
118
  def spawn(command: str, owner: str = "", repo: str = ""):