Support version suffix on git URL package installs#223
Merged
swissspidy merged 2 commits intomainfrom Mar 2, 2026
Merged
Conversation
…endor/package.git:dev-main) Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix errors installing command in development environment
Support version suffix on git URL package installs
Mar 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes wp package install when installing from a full git URL that includes a version suffix (e.g. ...repo.git:dev-main), ensuring the URL is still recognized as a git repository and the version is applied correctly.
Changes:
- Parse and split the
<git-url>.git:<version>pattern beforeis_git_repository()so.gitdetection works and the version is preserved. - Skip the GitHub default-branch API lookup when the version suffix is explicitly provided.
- Add a Behat scenario to cover installing from an HTTPS git URL with a version suffix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Package_Command.php | Extracts :version from git URLs ending in .git before git-repo detection; avoids default-branch lookup when version is present. |
| features/package-install.feature | Adds an acceptance scenario validating install/uninstall via https://...repo.git:dev-main. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
swissspidy
approved these changes
Mar 2, 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.
Installing a package via a full git URL with a version suffix (e.g.
https://github.com/vendor/package.git:dev-main) fails with a misleading error becauseis_git_repository()checks for a.gitsuffix and the appended version breaks that check, causing the input to fall through to the shortened-identifier path:Changes
src/Package_Command.php— Before theis_git_repository()check, detect and split the<url>.git:<version>pattern. The extracted version bypasses the subsequentget_github_default_branch()API call since the version is already known.features/package-install.feature— New@github-apiscenario covering HTTPS git URL with a version suffix.Original prompt
This section details on the original issue you should resolve
<issue_title>Errors installing command into development environment</issue_title>
<issue_description>## Bug Report
Describe the current, buggy behavior
I read the contributing guidlines for installing a command, but got an error that looked like a regression of the problem described in wp-cli/wp-cli#5602.
When trying to work around it with the
:dev-mainsuffix, wp-cli baulked at thehttps:scheme and the ssh aliasgithub:(which shortens the usualgit@github.comand selects the right key).Maybe I'm just doing it wrong but it seems like odd behaviour when supplying legitimate URLs that work with Git.
Describe how other contributors can replicate this bug
Install command using
wp package install ...with an HTTP or ssh alias URL. It may do the same with the explicitgit@...URL.See shell output below.
Describe what you expect as the correct outcome
Command to install as per docs, or docs are updated to new expected command.
It worked when I used
wp package install wp-cli/search-replace-command:dev-main.Let us know what environment you are running this on
Provide additional context/screenshots
Shell output: