Sitelet https://github.com/thiter/obsidian-github-sync-multi-platform/pull/4
Skip to content

fix: support syncing to a brand-new empty repository - #4

Open
pulipulichen wants to merge 1 commit into
thiter:masterfrom
pulipulichen:fix/empty-repository-sync
Open

pulipulichen wants to merge 1 commit into
thiter:masterfrom
pulipulichen:fix/empty-repository-sync

Conversation

@pulipulichen

Copy link
Copy Markdown

Summary

Fix synchronization when the target GitHub repository is brand new and has no commits yet.

Problem

getTree() calls the GitHub Trees API for the configured branch. For a newly created empty repository, GitHub responds with:

409 Git Repository is empty.

The plugin currently treats this as a fatal error, so the initial sync cannot proceed far enough to create the first commit.

Fix

Detect this specific empty-repository response and return an empty tree:

{ sha: "", url: "", tree: [], truncated: false }

This lets the existing sync flow continue and create the first files/commit through the Contents API.

Other 409 responses are still treated as errors.

Testing

Tested with a brand-new empty GitHub repository; the initial synchronization can now proceed successfully.

This PR is intentionally scoped to the empty-repository fix only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant