Conversation
Contributor
Author
|
Fixes #542 |
Contributor
|
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
Add first-class support for changing the branch of an installed app from the Pilot Admin UI.
Pilot already had an internal
SwitchBranchTask, but there was no Admin UI/API workflow to use it. This PR exposes that functionality and makes branch switching robust for shallow and single-branch clones.Changes
Add
POST /apps/<name>/actions/switch-branch.Add Change branch to installed app actions.
Load available remote branches using the existing Git branch endpoint.
Queue the existing
SwitchBranchTaskfor the actual switch.Add optional Force switch behavior to discard tracked and untracked local changes.
Fetch the target branch using an explicit remote-tracking refspec:
Keep
.git/configsynchronized after switching:remote.origin.fetchentries for single-branch clones;refs/heads/*fetch configuration for full clones;branch.<name>.remote = origin;branch.<name>.merge = refs/heads/<name>.Persist the selected branch back to
bench.toml.Retain the existing validation, reinstall, asset build, and worker reload behavior.
Document the new API.
Why
Apps may move away from deprecated branches, while existing Pilot installations remain configured and checked out on the old branch.
For single-branch clones, simply running:
may only populate
FETCH_HEADand leave the clone's persistent fetch configuration still pointing at the deprecated branch.This can leave three states inconsistent:
This PR keeps all three synchronized through a single managed Pilot operation.
Safety
Normal branch switching preserves local changes using the existing stash behavior.
Force switching is explicit and permanently discards tracked and untracked working-tree changes before switching.
Tests
Added coverage for:
SwitchBranchTask;.git/configrefspec and upstream tracking updates;