diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bc168b..c834d01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,16 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: [2.7, "3.0", 3.1, 3.2] + ruby-version: [2.6, 2.7, "3.0", 3.1, 3.2] bundler-version: [2.4.19, 2.4.22, 2.5.2] exclude: + - ruby-version: 2.6 + bundler-version: 2.5.2 - ruby-version: 2.7 bundler-version: 2.5.2 env: BUNDLER_VERSION: ${{ matrix.bundler-version }} + BUNDLE_LOCKFILE: active steps: - uses: actions/checkout@v3 - name: Set up Ruby diff --git a/.gitignore b/.gitignore index b3974b5..7aa235e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /*.gem -/pkg +/.bundle/ +/pkg/ diff --git a/.rubocop.yml b/.rubocop.yml index 3e9e3af..2cd88ee 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,10 @@ require: - rubocop-rake AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 2.6 + +Bundler/DuplicatedGem: + Enabled: false Naming/FileName: Exclude: diff --git a/Gemfile b/Gemfile index 468ec28..ce42cac 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,24 @@ source "https://rubygems.org" # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec + +plugin "bundler-multilock", path: "." +return unless Plugin.installed?("bundler-multilock") + +Plugin.send(:load_plugin, "bundler-multilock") + +lockfile active: RUBY_VERSION >= "2.7" do + gem "debug", "~> 1.9", require: false + gem "irb", "~> 1.11", require: false + gem "rubocop-inst", "~> 1.0", require: false + gem "rubocop-rake", "~> 0.6", require: false + gem "rubocop-rspec", "~> 2.24", require: false + gem "stringio", "~> 3.1", require: false +end + +lockfile "ruby-2.6", active: RUBY_VERSION < "2.7" do + # newer versions of these gems are not compatible with Ruby > 2.6 + gem "debug", "1.8.0", require: false + gem "irb", "1.6.3", require: false + gem "stringio", "3.0.6", require: false +end diff --git a/Gemfile.lock b/Gemfile.lock index e477ee9..f64c5fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,12 +9,12 @@ GEM specs: ast (2.4.2) base64 (0.1.1) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) + debug (1.9.0) + irb (~> 1.10) + reline (>= 0.3.8) diff-lcs (1.5.0) - io-console (0.6.0) - irb (1.8.1) + io-console (0.7.1) + irb (1.11.0) rdoc reline (>= 0.3.8) json (2.6.3) @@ -23,15 +23,15 @@ GEM parser (3.2.2.3) ast (~> 2.4.1) racc - psych (5.1.0) + psych (5.1.2) stringio racc (1.7.1) rainbow (3.1.1) rake (13.0.6) - rdoc (6.5.0) + rdoc (6.6.2) psych (>= 4.0.0) regexp_parser (2.8.1) - reline (0.3.8) + reline (0.4.1) io-console (~> 0.5) rexml (3.2.6) rspec (3.12.0) @@ -78,7 +78,7 @@ GEM rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) - stringio (3.0.8) + stringio (3.1.0) unicode-display_width (2.4.2) PLATFORMS @@ -90,12 +90,14 @@ PLATFORMS DEPENDENCIES bundler-multilock! - debug (~> 1.8) + debug (~> 1.9) + irb (~> 1.11) rake (~> 13.0) rspec (~> 3.12) rubocop-inst (~> 1.0) rubocop-rake (~> 0.6) rubocop-rspec (~> 2.24) + stringio (~> 3.1) BUNDLED WITH 2.5.2 diff --git a/Gemfile.ruby-2.6.lock b/Gemfile.ruby-2.6.lock new file mode 100644 index 0000000..7ad6156 --- /dev/null +++ b/Gemfile.ruby-2.6.lock @@ -0,0 +1,51 @@ +PATH + remote: . + specs: + bundler-multilock (1.2.1) + bundler (>= 2.4.19, < 2.6) + +GEM + remote: https://rubygems.org/ + specs: + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + diff-lcs (1.5.0) + io-console (0.7.1) + irb (1.6.3) + reline (>= 0.3.0) + rake (13.0.6) + reline (0.4.1) + io-console (~> 0.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + stringio (3.0.6) + +PLATFORMS + aarch64-linux + arm64-darwin + ruby + x86_64-darwin + x86_64-linux + +DEPENDENCIES + bundler-multilock! + debug (= 1.8.0) + irb (= 1.6.3) + rake (~> 13.0) + rspec (~> 3.12) + stringio (= 3.0.6) + +BUNDLED WITH + 2.5.2 diff --git a/bundler-multilock.gemspec b/bundler-multilock.gemspec index cdf70db..9016c2a 100644 --- a/bundler-multilock.gemspec +++ b/bundler-multilock.gemspec @@ -14,14 +14,10 @@ Gem::Specification.new do |spec| spec.files = Dir.glob("lib/**/*") + %w[plugins.rb] spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.7" + spec.required_ruby_version = ">= 2.6" spec.add_dependency "bundler", ">= 2.4.19", "< 2.6" - spec.add_development_dependency "debug", "~> 1.8" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.12" - spec.add_development_dependency "rubocop-inst", "~> 1.0" - spec.add_development_dependency "rubocop-rake", "~> 0.6" - spec.add_development_dependency "rubocop-rspec", "~> 2.24" end diff --git a/lib/bundler/multilock/check.rb b/lib/bundler/multilock/check.rb index 662f381..2c73d36 100644 --- a/lib/bundler/multilock/check.rb +++ b/lib/bundler/multilock/check.rb @@ -190,7 +190,8 @@ def check(lockfile_definition) private def cache_reverse_dependencies(lockfile) - reverse_dependencies = Hash.new { |h, k| h[k] = Gem::Requirement.default_prerelease } + # can use Gem::Requirement.default_prelease when Ruby 2.6 support is dropped + reverse_dependencies = Hash.new { |h, k| h[k] = Gem::Requirement.new(">= 0.a") } lockfile.dependencies.each_value do |spec| reverse_dependencies[spec.name].requirements.concat(spec.requirement.requirements) diff --git a/lib/bundler/multilock/ext/plugin/dsl.rb b/lib/bundler/multilock/ext/plugin/dsl.rb index 36a2afd..4c8eecb 100644 --- a/lib/bundler/multilock/ext/plugin/dsl.rb +++ b/lib/bundler/multilock/ext/plugin/dsl.rb @@ -7,7 +7,7 @@ module PluginExt module DSL ::Bundler::Plugin::DSL.include(self) - def lockfile(...) + def lockfile(*, **) # pass end end diff --git a/lib/bundler/multilock/ext/source.rb b/lib/bundler/multilock/ext/source.rb index 845b30b..2df72fa 100644 --- a/lib/bundler/multilock/ext/source.rb +++ b/lib/bundler/multilock/ext/source.rb @@ -6,7 +6,7 @@ module Ext module Source ::Bundler::Source.prepend(self) - def print_using_message(...) + def print_using_message(*) return if Bundler.settings[:suppress_install_using_messages] super diff --git a/spec/bundler/multilock_spec.rb b/spec/bundler/multilock_spec.rb index 32966ed..e5ff5ad 100644 --- a/spec/bundler/multilock_spec.rb +++ b/spec/bundler/multilock_spec.rb @@ -303,28 +303,28 @@ it "syncs from a parent lockfile" do with_gemfile(<<~RUBY) do lockfile do - gem "activesupport", "~> 7.0.0" + gem "activesupport", "~> 6.1.0" end - lockfile("6.1") do - gem "activesupport", "~> 6.1.0" + lockfile("6.0") do + gem "activesupport", "~> 6.0.0" end - lockfile("6.1-alt", parent: "6.1") do - gem "activesupport", "> 6.0", "< 7.2" + lockfile("6.0-alt", parent: "6.0") do + gem "activesupport", "> 5.2", "< 7.2" end RUBY invoke_bundler("install") - default = invoke_bundler("info activesupport").split("\n").first - six_one = invoke_bundler("info activesupport", env: { "BUNDLE_LOCKFILE" => "6.1" }).split("\n").first - alt = invoke_bundler("info activesupport", env: { "BUNDLE_LOCKFILE" => "6.1-alt" }).split("\n").first + default = invoke_bundler("info activesupport") + six_oh = invoke_bundler("info activesupport 2> /dev/null", env: { "BUNDLE_LOCKFILE" => "6.0" }) + alt = invoke_bundler("info activesupport 2> /dev/null", env: { "BUNDLE_LOCKFILE" => "6.0-alt" }) - expect(default).to include("7.0") - expect(default).not_to eq six_one - expect(six_one).to include("6.1") - # alt is the same as 6.1, even though it should allow 7.1 - expect(alt).to eq six_one + expect(default).to include("6.1") + expect(default).not_to eq six_oh + expect(six_oh).to include("6.0") + # alt is the same as 6.0, even though it should allow 6.1 + expect(alt).to eq six_oh end end @@ -359,23 +359,23 @@ it "notifies about mismatched versions between different lockfiles" do with_gemfile(<<~RUBY) do lockfile do - gem "activesupport", ">= 6.1", "< 7.2" + gem "activesupport", ">= 6.0", "< 7.0" end lockfile("full") do - gem "activesupport", "6.1.7.6" + gem "activesupport", "6.0.6.1" end RUBY expect do invoke_bundler("install") - end.to raise_error(Regexp.new("activesupport \\(6.1.7.6\\) in Gemfile.full.lock " \ + end.to raise_error(Regexp.new("activesupport \\(6.0.6.1\\) in Gemfile.full.lock " \ "does not match the parent lockfile's version")) end end it "notifies about mismatched versions between different lockfiles for sub-dependencies" do with_gemfile(<<~RUBY) do - gem "activesupport", "7.0.4.3" # depends on tzinfo ~> 2.0, so will get >= 2.0.6 + gem "activesupport", "6.1.7.6" # depends on tzinfo ~> 2.0, so will get >= 2.0.6 lockfile("full") do gem "tzinfo", "2.0.5" @@ -392,18 +392,18 @@ it "allows mismatched explicit dependencies by default" do with_gemfile(<<~RUBY) do lockfile do - gem "activesupport", "~> 6.1.0" + gem "activesupport", "~> 6.0.0" end lockfile("new") do - gem "activesupport", "7.0.4.3" + gem "activesupport", "6.1.7.6" end RUBY invoke_bundler("install") # no error - expect(File.read("Gemfile.lock")).to include("6.1.") - expect(File.read("Gemfile.lock")).not_to include("7.0.4.3") - expect(File.read("Gemfile.new.lock")).not_to include("6.1.") - expect(File.read("Gemfile.new.lock")).to include("7.0.4.3") + expect(File.read("Gemfile.lock")).to include("6.0.") + expect(File.read("Gemfile.lock")).not_to include("6.1.7.6") + expect(File.read("Gemfile.new.lock")).not_to include("6.0.") + expect(File.read("Gemfile.new.lock")).to include("6.1.7.6") end end @@ -686,8 +686,8 @@ with_gemfile(<<~RUBY) do gemspec - lockfile("rails-7.0", default: true) do - gem "activesupport", "~> 7.0.0" + lockfile("rails-6.1", default: true) do + gem "activesupport", "~> 6.1.0" end RUBY create_local_gem("test", subdirectory: false) @@ -701,11 +701,11 @@ it "does not re-sync lockfiles that have conflicting sub-dependencies" do with_gemfile(<<~RUBY) do lockfile do - gem "activemodel", "~> 7.1.0" + gem "activemodel", "~> 6.1.0" end - lockfile("rails-7.0") do - gem "activemodel", "~> 7.0.0" + lockfile("rails-6.0") do + gem "activemodel", "~> 6.0.0" end RUBY output = invoke_bundler("install") @@ -718,7 +718,7 @@ it "removes now-missing explicit dependencies from secondary lockfiles" do with_gemfile(<<~RUBY) do - gem "inst-jobs", "3.1.13" + gem "inst-jobs", "3.1.6" gem "activerecord-pg-extensions" lockfile("alt") {} @@ -726,7 +726,7 @@ invoke_bundler("install") write_gemfile(<<~RUBY) - gem "inst-jobs", "3.1.13" + gem "inst-jobs", "3.1.6" lockfile("alt") {} RUBY @@ -739,7 +739,7 @@ it "does not evaluate the default lockfile at all if an alternate is active, " \ "without specifying that lockfile explicitly" do with_gemfile(<<~RUBY) do - gem "inst-jobs", "3.1.13" + gem "inst-jobs", "3.1.6" lockfile active: ENV["ALTERNATE"] != "1" do raise "evaluated!" if ENV["ALTERNATE"] == "1"