Skip to content

Commit

Permalink
Remove extra references to composer v1
Browse files Browse the repository at this point in the history
  • Loading branch information
amazimbe committed Jan 8, 2025
1 parent be5f774 commit 2dbbd81
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,6 @@ def handle_composer_errors(error)
raise PrivateSourceAuthenticationFailure, source
end

# NOTE: This error is raised by composer v1
if error.message.include?("Argument 1 passed to Composer")
msg = "One of your Composer plugins is not compatible with the " \
"latest version of Composer. Please update Composer and " \
"try running `composer update` to debug further."
raise DependencyFileNotResolvable, msg
end

# NOTE: This error is raised by composer v2 and includes helpful
# information about which plugins or dependencies are not compatible
if error.message.include?("Your requirements could not be resolved")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def initialize(extensions)
MISSING_IMPLICIT_PLATFORM_REQ_REGEX =
%r{
(?<!with|for|by)\sext\-[^\s\/]+\s.*?\s(?=->)|
(?<=requires\s)php(?:\-[^\s\/]+)?\s.*?\s(?=->)| # composer v1
(?<=require\s)php(?:\-[^\s\/]+)?\s.*?\s(?=->) # composer v2
}x
VERSION_REGEX = /[0-9]+(?:\.[A-Za-z0-9\-_]+)*/
Expand Down
10 changes: 3 additions & 7 deletions composer/spec/dependabot/composer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# composer/helpers/v2/composer.lock, you also need to bump it in the
# Dockerfile.

expect(helper_composer_version(major_version: "v2")).to eq(native_composer_version(major_version: "v2"))
expect(helper_composer_version(major_version: "v2")).to eq(native_composer_version)
end

private
Expand All @@ -30,12 +30,8 @@ def helper_composer_version(major_version:)
JSON.parse(composer_lock)["packages"].find { |p| p["name"] == "composer/composer" }["version"]
end

def native_composer_version(major_version:)
native_composer_output = if major_version == "v1"
Dependabot::SharedHelpers.run_shell_command("composer1 --version")
else
Dependabot::SharedHelpers.run_shell_command("composer --version")
end
def native_composer_version
native_composer_output = Dependabot::SharedHelpers.run_shell_command("composer --version")
native_composer_output.match(/composer\s+version\s+(\d+\.\d+\.\d+)/i).captures.first
end
end

0 comments on commit 2dbbd81

Please sign in to comment.