From 6d731ffdcad563f490df67fa860e70b81b3b1e2d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 10:26:14 +0000 Subject: [PATCH 1/2] Initial plan From ed092d10063f4893f4150a6f20ea35ccd6e31246 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 10:32:12 +0000 Subject: [PATCH 2/2] Support version suffix in git URL installs (e.g. https://github.com/vendor/package.git:dev-main) Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/package-install.feature | 24 ++++++++++++++++++++++++ src/Package_Command.php | 9 ++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/features/package-install.feature b/features/package-install.feature index efef40b5..495d77af 100644 --- a/features/package-install.feature +++ b/features/package-install.feature @@ -274,6 +274,30 @@ Feature: Install WP-CLI packages wp-cli/google-sitemap-generator-cli """ + @github-api + Scenario: Install a package from a Git URL with a version suffix + Given an empty directory + + When I run `wp package install https://github.com/wp-cli/google-sitemap-generator-cli.git:dev-main` + Then STDOUT should contain: + """ + Installing package wp-cli/google-sitemap-generator-cli (dev-main) + """ + And STDOUT should contain: + """ + Registering https://github.com/wp-cli/google-sitemap-generator-cli.git as a VCS repository... + """ + And STDOUT should contain: + """ + Success: Package installed. + """ + + When I run `wp package uninstall wp-cli/google-sitemap-generator-cli` + Then STDOUT should contain: + """ + Success: Uninstalled package. + """ + @github-api Scenario: Install a package from a Git URL with mixed-case git name but lowercase composer.json name Given an empty directory diff --git a/src/Package_Command.php b/src/Package_Command.php index e39dcf68..12e784a9 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -222,8 +222,15 @@ public function install( $args, $assoc_args ) { $git_package = false; $dir_package = false; $version = ''; + // Parse version suffix from a git URL (e.g. https://github.com/vendor/package.git:dev-main). + if ( preg_match( '#^(.+\.git):([^:]+)$#', $package_name, $url_version_matches ) ) { + $package_name = $url_version_matches[1]; + $version = $url_version_matches[2]; + } if ( $this->is_git_repository( $package_name ) ) { - $version = "dev-{$this->get_github_default_branch( $package_name, $insecure )}"; + if ( '' === $version ) { + $version = "dev-{$this->get_github_default_branch( $package_name, $insecure )}"; + } $git_package = $package_name; $matches = []; if ( preg_match( '#([^:\/]+\/[^\/]+)\.git#', $package_name, $matches ) ) {