From 52dac2c4b0a7364d44a267296d0354e87cf06d71 Mon Sep 17 00:00:00 2001 From: NeverSightAI Date: Fri, 27 Feb 2026 18:31:20 +0800 Subject: [PATCH] Update archiving workflow to commit every successful archive immediately. Adjust maximum file size limit to 95 MB to prevent GitHub LFS rejections. Enhance error handling in the archive script to undo commits blocked by large files and improve retry logic for push failures. --- .github/workflows/archive-repos.yml | 2 +- scripts/archive-repos.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/archive-repos.yml b/.github/workflows/archive-repos.yml index d6554abc..ffb0a3c7 100644 --- a/.github/workflows/archive-repos.yml +++ b/.github/workflows/archive-repos.yml @@ -16,7 +16,7 @@ on: commit_every: description: "Commit & push every N successful archives" required: false - default: "5" + default: "1" owner_filter: description: "Only archive repos from this owner (leave empty for all)" required: false diff --git a/scripts/archive-repos.py b/scripts/archive-repos.py index 40042dd1..e7e58c39 100644 --- a/scripts/archive-repos.py +++ b/scripts/archive-repos.py @@ -36,7 +36,7 @@ GITHUB_REPO_PATTERN = re.compile( MAX_WORKERS = 3 CLONE_TIMEOUT = 180 # seconds CODE2PROMPT_TIMEOUT = 60 # seconds — abandon large repos quickly -MAX_FILE_MB = 200 # skip output files larger than this +MAX_FILE_MB = 95 # GitHub hard-rejects files > 100 MB; keep safely below # Binary / large-asset extensions excluded from code2prompt output. # Keeps archive files focused on source code and avoids TOOLARGE rejections @@ -203,8 +203,17 @@ def git_commit_and_push(archive_dir: Path, count: int, push_retries: int = 5) -> except subprocess.CalledProcessError as e: err = e.stderr.decode().strip() if e.stderr else str(e) + # File too large for GitHub (LFS rejection) — undo this commit + # so it doesn't block all subsequent pushes. + if any(k in err for k in ("gh.io/lfs", "large files", + "exceeds GitHub's file size limit")): + print(f" [GIT] Push blocked by large file — undoing commit") + subprocess.run(["git", "reset", "HEAD~1"], capture_output=True) + return + if attempt >= push_retries: print(f" [GIT ERROR] push failed after {push_retries} retries: {err[:200]}") + subprocess.run(["git", "reset", "HEAD~1"], capture_output=True) return # Remote moved ahead (conflict) — rebase then retry @@ -218,6 +227,8 @@ def git_commit_and_push(archive_dir: Path, count: int, push_retries: int = 5) -> except subprocess.CalledProcessError as re_err: re_msg = re_err.stderr.decode().strip()[:200] if re_err.stderr else str(re_err) print(f" [GIT ERROR] rebase failed: {re_msg}") + subprocess.run(["git", "rebase", "--abort"], capture_output=True) + subprocess.run(["git", "reset", "HEAD~1"], capture_output=True) return # Network / timeout error (408, RPC failure, disconnect) — just retry @@ -230,9 +241,11 @@ def git_commit_and_push(archive_dir: Path, count: int, push_retries: int = 5) -> else: print(f" [GIT ERROR] push: {err[:200]}") + subprocess.run(["git", "reset", "HEAD~1"], capture_output=True) return print(f" [GIT ERROR] push failed after {push_retries} retries — giving up") + subprocess.run(["git", "reset", "HEAD~1"], capture_output=True) def archive_repo(