Skip to content

Fix remote clone retries with existing branches#380

Merged
adamziel merged 1 commit into
trunkfrom
codex/remote-clone-existing-branch-force
May 18, 2026
Merged

Fix remote clone retries with existing branches#380
adamziel merged 1 commit into
trunkfrom
codex/remote-clone-existing-branch-force

Conversation

@adamziel
Copy link
Copy Markdown
Contributor

What it does

Makes forkpress remote clone --branch <branch> behave predictably when the target branch already exists.

Without --force, ForkPress now fails before rsync or MySQL export/import and tells you to open the existing branch preview or use --force. With --force, ForkPress updates the remote cache and recreates the local branch from that cache.

Rationale

A retry after a partial or stale local branch could spend time syncing/importing the remote site and then fail with branch already exists. That left users looking at the vanilla main branch from forkpress init, even though the remote MySQL import had succeeded.

The retry path needs to be explicit: refuse early by default, and make --force rebuild the local branch from the freshly cloned remote data.

Implementation

Added a storage helper for detecting existing COW branches and a recreate cleanup path for branch birth metadata. remote clone --branch now preflights COW initialization and branch existence before sync. branch_remote_site() accepts replace_existing and deletes/recreates the branch only when the caller passed --force.

Docs now call out that http://wp.localhost:18080/ is the local main branch, while --branch production-main previews at http://production-main.wp.localhost:18080/.

Testing instructions

php -l scripts/cow/mysql_export.php
php -l scripts/cow/mysql_import_sqlite.php
make test-cow-mysql-import
CARGO_TARGET_DIR=/tmp/forkpress-cargo-target-remote-fix FORKPRESS_RUNTIME_BUNDLE=/dev/null cargo test -p forkpress-storage remote
CARGO_TARGET_DIR=/tmp/forkpress-cargo-target-remote-fix FORKPRESS_RUNTIME_BUNDLE=/dev/null cargo test -p forkpress-cli
FORKPRESS_E2E_ONLY=remote-cache tests/cow/e2e.sh /tmp/forkpress-cargo-target-remote-fix/debug/forkpress
npm test
npm run build
cargo fmt --check
git diff --check

@adamziel adamziel merged commit de76b66 into trunk May 18, 2026
13 checks passed
@adamziel adamziel deleted the codex/remote-clone-existing-branch-force branch May 18, 2026 22:35
@adamziel adamziel mentioned this pull request May 18, 2026
adamziel added a commit that referenced this pull request May 18, 2026
## Release `v0.1.47`

Version bump and release metadata update for `v0.1.47`.

**Changelog draft:**
* Fix remote clone retries with existing branches
([#380](#380))

**Full changelog:**
v0.1.46...release/v0.1.47

## Next steps

1. **Review** the changes in this pull request.
2. **Push** any additional edits to this branch (`release/v0.1.47`).
3. **Merge** this pull request to publish `v0.1.47`.

Merging will automatically build ForkPress binaries, create a GitHub
release, and update the Homebrew formula.

Co-authored-by: Codex <codex@openai.com>
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.

2 participants