Conversation
Adds the WP Origin plugin, which makes WordPress posts and pages available as a Git remote. Users and coding agents can clone, pull, and push Markdown files using standard Git tooling, with WordPress as the source of truth. The plugin exposes a Git Smart HTTP endpoint at /wp-json/git/v1/md.git, backed by HTTP Basic Auth with application passwords. Posts and pages are serialized as Markdown with YAML front matter. Pushes validate staleness before applying changes and move deleted files to trash rather than destroying content. This commit also renames the Markdown fenced-code block language from `block` to `gutenberg` (the old name is still accepted on import), and adds a real end-to-end test script that boots a WordPress Playground instance, clones the repo, edits and pushes a post, and verifies that a stale push is rejected.
The round-trip tests lock in the byte-preservation promise: Markdown that enters WordPress and comes back out must be identical, and block markup that is exported to Markdown and pushed back must produce the same blocks. 29 test cases cover paragraphs, headings, lists, tables, blockquotes, images, links, gutenberg fences (opaque unsupported-block preservation), front matter, and mixed content. The plugin gains several stability improvements: the repository now lives in a per-request temp directory that is always cleaned up in a finally block, binary Git responses bypass WordPress REST JSON encoding via a rest_pre_serve_request hook, permission checks cover both editing existing posts and creating new ones, and metadata values are correctly wrapped in arrays as BlocksWithMetadata requires.
|
@artpi review ping for the WP Origin Git remote work and Docker e2e coverage. |
|
Amazing! 🤯 After a few hacks i was able to make it work: I hit a packaging-only fatal when testing the uploaded WP Origin plugin zip in a real WordPress install: Root cause: the packaged The existing Docker e2e path did not catch this because it uses the dev bootstrap/mounted repo path, not the packaged phar path. For local testing I fixed the built artifact by removing
After rebuilding the plugin zip, the fatal went away and the needed classes still autoloaded. Suggested upstream fix: build WP plugin phars/zips without |
What it does
Exposes WordPress posts and pages as a Git remote at
/wp-json/git/v1/md.git, with Markdown export/import, stale-push protection, and real end-to-end coverage for stockgit.This branch also makes the WP Origin flow runnable in Docker via
bin/test-wp-origin-git-actions-docker.sh.Rationale
The PRD only matters if the full loop works with the real CLI:
git clone, edit Markdown,git push, and have WordPress reflect the change. That required two pieces:git, not just in-process unit tests.I kept the default
sandboxservice onnetwork_mode: noneand added a dedicatedsandbox-wp-origin-e2eservice instead, because WordPress Playground still needs network access during boot.Implementation
wp-originplugin runtime for/wp-json/git/v1/md.git.post/*.mdandpage/*.mdwith front matter.gitretries correctly with WordPress application passwords.This includes the Git groundwork from #237 because WP Origin depends on those real-CLI compatibility fixes.
Testing instructions
Repo-wide
composer lintstill reports the existing warning baseline outside this change set.Review ping: @artpi