fix: set-remote with project ID outside a project root#53
Merged
miguelsanchez-upsun merged 3 commits intomainfrom Apr 28, 2026
Merged
fix: set-remote with project ID outside a project root#53miguelsanchez-upsun merged 3 commits intomainfrom
miguelsanchez-upsun merged 3 commits intomainfrom
Conversation
The unified Selector::getSelection() reads project IDs from the --project option only, so the ProjectSetRemoteCommand argument was discarded and the selector then tried to detect the current project from disk. In a fresh checkout (e.g. CI runners) that produced a RootNotFoundException even when the project ID was supplied as an argument. Bypass getSelection() when an argument is given and load the project directly via the API, matching the pre-5.x behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Api service ignores the project host when an api.base_url is configured (always the case for Upsun), so passing it through from Identifier::identify() is dead weight. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an integration test exercising the set-remote command across the main code paths: the regression case with a project ID in a fresh git checkout (which previously failed with RootNotFoundException), an unknown project ID, running outside a git repository, an unset call with nothing mapped, and the non-interactive case with no argument. Adds a 'dir' field on cmdFactory so commands can be run from a specific working directory rather than the default temp directory. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ef498ad to
af67dff
Compare
miguelsanchez-upsun
approved these changes
Apr 28, 2026
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
upsun set-remote PROJECT_IDfailed withRootNotFoundExceptionwhen run in a fresh Git checkout (no.platform/local/project.yamlyet) — the typical CI / pipelines case.The unified
Selector::getSelection()reads project IDs from the--projectoption only, so the positionalprojectargument onset-remotewas silently dropped. The selector then fell back togetCurrentProject(), found no project root, and threw — even though the user had supplied the ID. The pre-5.xCommandBase::selectProject(\$projectId)call took the argument directly, which is what this restores.Changes
legacy/src/Command/Project/ProjectSetRemoteCommand.php: when a project ID argument is given, look it up viaApi::getProject()directly and skipgetSelection(). Fall back togetSelection()only when no argument is given (interactive prompt or env-var path).integration-tests/set_remote_test.go: covers five paths — the regression case (project ID in a fresh git repo), unknown project ID, outside a git repo, unset with nothing mapped, and no-arg in non-interactive mode.integration-tests/tests.go: adds adirfield oncmdFactoryso a test can run the CLI inside an ad-hoc git repo.The regression subtest reproduces the bug verbatim (
Selector.php line 295: Could not determine the current project) when run against the unfixed PHP and passes with the fix.🤖 Generated with Claude Code