feat: add POST /sync/all endpoint and make Push idempotent#745
Merged
Conversation
- PushFiles now skips commit creation when tree SHA is unchanged, preventing empty commits on repeated calls - Added Syncer.SyncAll() to push and/or pull all GitSync-enabled settings tenants in a single operation - Added POST /sync/all handler (admin-only) accepting direction (push/pull/both), delete_orphans, and commit_message - Per-tenant errors are captured in results[].error without aborting remaining tenants - Updated spec/openapi.json with new endpoint and response schemas Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the manual direction parameter. Instead, per tenant we compare the remote .sync-meta.yaml syncedAt against the local LastPushedAt: - GitHub newer → pull - local newer or equal → push (idempotent: no commit if tree unchanged) SyncAllResult gains a direction field showing which was chosen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PushFilesがツリー SHA 不変の場合にコミットをスキップするよう修正し、Push を冪等化Syncer.SyncAll()を追加 — GitSync 有効な全テナントを一括で push/pullPOST /sync/allエンドポイントを追加 (admin 専用)spec/openapi.jsonにエンドポイントとスキーマを追加変更内容
Push の冪等化 (
github_client.go)CreateTree後に新旧ツリー SHA を比較し、同一であればコミットを作成しない。これにより内容が変わっていない場合の空コミットを防ぐ。POST /sync/all(handlers.go,syncer.go,types.go)リクエスト:
{ "direction": "push" | "pull" | "both", "delete_orphans": false, "commit_message": "" }レスポンス:
{ "synced_at": "2026-05-17T00:00:00Z", "results": [ { "settings_name": "takutakahashi", "push": { "commit_sha": "...", "pushed_at": "...", "summary": { "files_written": 5 } }, "pull": { "pulled_at": "...", "summary": { "files_written": 3 } } } ] }テナントごとのエラーは
results[].errorに格納され、他テナントの処理を中断しない。Test plan
make build→ OKmake lint→ 0 issues🤖🐮 Generated with Claude Code