Skip to content

Commit 5d64b96

Browse files
myelinated-wackerowclaudewackerow
committed
feat: commit per batch + squash at end
Zero data loss: commit+push after every batch (~1,248 commits during run). Final workflow step squashes all into one clean commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-Authored-By: wackerow <54227730+wackerow@users.noreply.github.com>
1 parent c025253 commit 5d64b96

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

.github/workflows/branch-task.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ jobs:
4646
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
4747
run: npx tsx scripts/generate-translations-sdk.ts
4848

49-
- name: Final commit and push
49+
- name: Squash all translation commits into one
5050
run: |
51-
git add scripts/translations/
52-
if git diff --staged --quiet; then
53-
echo "No new translations to commit"
54-
else
55-
git commit -m "data: glossary translations (final batch)
51+
# Find the commit before the first translation commit
52+
BASE=$(git log --oneline --format="%H" -- scripts/translations/ | tail -1)
53+
PARENT=$(git log --oneline --format="%H" ${BASE}^ -1 2>/dev/null || echo "")
54+
if [ -n "$PARENT" ]; then
55+
echo "Squashing translation commits since $PARENT"
56+
git reset --soft $PARENT
57+
git add scripts/translations/
58+
git commit -m "data: glossary translations (519 terms x 24 languages)
59+
60+
Generated via Gemini 3.1 Pro Preview with @google/genai SDK.
61+
16 concurrent streams, 10 terms per batch.
5662
5763
Co-Authored-By: Gemini <noreply@google.com>"
58-
git push
64+
git push --force-with-lease
65+
else
66+
echo "No translation commits to squash"
5967
fi

scripts/generate-translations-sdk.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,14 @@ async function processLanguage(
636636
langGenerated += result.generated
637637
langFailed += result.failed
638638

639-
// Save after each batch (incremental)
639+
// Save and commit after each batch (zero data loss)
640640
saveTranslations(lang.code, existing)
641+
commitProgress(lang.code)
641642
}
642643

643644
const finalCount = Object.keys(existing).length
644645
log(`[${lang.code}] Done: ${finalCount}/${totalTerms} terms`)
645646

646-
// Commit progress so work isn't lost if the action crashes
647-
commitProgress(lang.code)
648-
649647
return { generated: langGenerated, failed: langFailed, skipped: 0 }
650648
}
651649

0 commit comments

Comments
 (0)