Skip to content

Commit

Permalink
Adjust requirements_update_strategy to fix pub crashes (#303)
Browse files Browse the repository at this point in the history
* Use strings for requirements update strategy

Dependabot's pub package manager only supports string values for requirements_update_strategy, not symbols

Adjust update script to pass in strings instead of symbols so that pub can work

* Special case the version strategy for pub

Add a special case for pub version strategies instead of using strings for all package managers, for conservatism
  • Loading branch information
ko16a46 authored Jun 27, 2022
1 parent f84d34e commit bf2c335
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/script/update-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
requirements_update_strategy_raw = ENV["DEPENDABOT_VERSIONING_STRATEGY"] || "auto"
$options[:requirements_update_strategy] = VERSIONING_STRATEGIES.fetch(requirements_update_strategy_raw)

# For npm_and_yarn, we must correct the strategy to one allowed
# For npm_and_yarn & composer, we must correct the strategy to one allowed
# https://github.com/dependabot/dependabot-core/blob/5ec858331d11253a30aa15fab25ae22fbdecdee0/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/requirements_updater.rb#L18-L19
# https://github.com/dependabot/dependabot-core/blob/5926b243b2875ad0d8c0a52c09210c4f5f274c5e/composer/lib/dependabot/composer/update_checker/requirements_updater.rb#L23-L24
if $package_manager == "npm_and_yarn" || $package_manager == "composer"
Expand All @@ -147,6 +147,19 @@
$options[:requirements_update_strategy] = :bump_versions
end
end

# For pub, we also correct the strategy
# https://github.com/dependabot/dependabot-core/blob/ca9f236591ba49fa6e2a8d5f06e538614033a628/pub/lib/dependabot/pub/update_checker.rb#L110
if $package_manager == "pub"
strategy = $options[:requirements_update_strategy]
if strategy == :auto
$options[:requirements_update_strategy] = nil
elsif strategy == :lockfile_only
$options[:requirements_update_strategy] = "bump_versions"
else
$options[:requirements_update_strategy] = strategy.to_s
end
end
end

####################################################
Expand Down

0 comments on commit bf2c335

Please sign in to comment.