Module: Dependabot::Composer::Helpers
- Defined in:
- lib/dependabot/composer/helpers.rb
Constant Summary collapse
- COMPOSER_V2_NAME_REGEX =
From composers json-schema: getcomposer.org/schema.json
%r{^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$}
- PLATFORM_PACKAGE_REGEX =
/ ^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)* |composer-(?:plugin|runtime)-api)$ /x
- FAILED_GIT_CLONE_WITH_MIRROR =
/^Failed to execute git clone --(mirror|checkout)[^']*'(?<url>[^']*?)'/
- FAILED_GIT_CLONE =
/^Failed to clone (?<url>.*?)/
Class Method Summary collapse
- .composer_version(composer_json, parsed_lockfile = nil) ⇒ Object
- .dependency_url_from_git_clone_error(message) ⇒ Object
Class Method Details
.composer_version(composer_json, parsed_lockfile = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dependabot/composer/helpers.rb', line 20 def self.composer_version(composer_json, parsed_lockfile = nil) if parsed_lockfile && parsed_lockfile["plugin-api-version"] version = Composer::Version.new(parsed_lockfile["plugin-api-version"]) return version.canonical_segments.first == 1 ? "1" : "2" else return "1" if composer_json["name"] && composer_json["name"] !~ COMPOSER_V2_NAME_REGEX return "1" if invalid_v2_requirement?(composer_json) end "2" end |
.dependency_url_from_git_clone_error(message) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dependabot/composer/helpers.rb', line 32 def self.dependency_url_from_git_clone_error() if .match?(FAILED_GIT_CLONE_WITH_MIRROR) dependency_url = .match(FAILED_GIT_CLONE_WITH_MIRROR).named_captures.fetch("url") raise "Could not parse dependency_url from git clone error: #{}" if dependency_url.empty? clean_dependency_url(dependency_url) elsif .match?(FAILED_GIT_CLONE) dependency_url = .match(FAILED_GIT_CLONE).named_captures.fetch("url") raise "Could not parse dependency_url from git clone error: #{}" if dependency_url.empty? clean_dependency_url(dependency_url) end end |