summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli/gem.rb21
-rw-r--r--lib/bundler/gem_helper.rb2
-rw-r--r--lib/bundler/source/git.rb22
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/defaults.rb2
-rw-r--r--lib/rubygems/errors.rb3
-rw-r--r--lib/rubygems/specification.rb4
-rw-r--r--lib/rubygems/specification_policy.rb2
-rw-r--r--spec/bundler/bundler/source/git_spec.rb45
-rw-r--r--spec/bundler/commands/newgem_spec.rb2
-rw-r--r--spec/bundler/support/hax.rb5
-rw-r--r--spec/bundler/support/path.rb9
-rw-r--r--test/rubygems/helper.rb2
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb10
-rw-r--r--test/rubygems/test_gem_specification.rb14
-rw-r--r--tool/bundler/rubocop_gems.rb.lock23
-rw-r--r--tool/bundler/test_gems.rb.lock2
18 files changed, 143 insertions, 29 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index b3bb025b89..02f19ad115 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -68,7 +68,7 @@ module Bundler
:bundler_version => bundler_dependency_version,
:git => use_git,
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
- :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
+ :required_ruby_version => required_ruby_version,
}
ensure_safe_gem_name(name, constant_array)
@@ -169,7 +169,7 @@ module Bundler
"For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
"and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
config[:rubocop] = true
- config[:rubocop_version] = Gem.ruby_version < Gem::Version.new("2.4.a") ? "0.81.0" : "1.7"
+ config[:rubocop_version] = rubocop_version
Bundler.ui.info "RuboCop enabled in config"
templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
end
@@ -350,5 +350,22 @@ module Bundler
def open_editor(editor, file)
thor.run(%(#{editor} "#{file}"))
end
+
+ def required_ruby_version
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
+ elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
+ else
+ "2.6.0"
+ end
+ end
+
+ def rubocop_version
+ if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
+ elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
+ else
+ "1.21"
+ end
+ end
end
end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index 6096adfa27..8e1dd7c4f2 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -76,7 +76,7 @@ module Bundler
tag_version { git_push(args[:remote]) } unless already_tagged?
end
- task "release:rubygem_push" do
+ task "release:rubygem_push" => "build" do
rubygem_push(built_gem_path) if gem_push?
end
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index fb13ca0578..679fb22574 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -42,7 +42,7 @@ module Bundler
%w[ref branch tag submodules].each do |opt|
out << " #{opt}: #{options[opt]}\n" if options[opt]
end
- out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
+ out << " glob: #{@glob}\n" unless default_glob?
out << " specs:\n"
end
@@ -75,12 +75,20 @@ module Bundler
git_proxy.branch
end
- rev = " (at #{at}@#{shortref_for_display(revision)})"
+ rev = "at #{at}@#{shortref_for_display(revision)}"
rescue GitError
""
end
- "#{@safe_uri}#{rev}"
+ specifiers = [rev, glob_for_display].compact
+ suffix =
+ if specifiers.any?
+ " (#{specifiers.join(", ")})"
+ else
+ ""
+ end
+
+ "#{@safe_uri}#{suffix}"
end
def name
@@ -282,6 +290,14 @@ module Bundler
ref[0..11]
end
+ def glob_for_display
+ default_glob? ? nil : "glob: #{@glob}"
+ end
+
+ def default_glob?
+ @glob == DEFAULT_GLOB
+ end
+
def uri_hash
if uri =~ %r{^\w+://(\w+@)?}
# Downcase the domain component of the URI
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index cf4965c0db..23a568c8ba 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.2.28".freeze
+ VERSION = "2.2.29".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index ebe9d7badd..3c48f2a8ac 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.2.28".freeze
+ VERSION = "3.2.29".freeze
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index e95bc06792..923b60f31f 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -73,7 +73,7 @@ module Gem
# Path to specification files of default gems.
def self.default_specifications_dir
- File.join(Gem.default_dir, "specifications", "default")
+ @default_specifications_dir ||= File.join(Gem.default_dir, "specifications", "default")
end
##
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index abee20651e..86f0d1da14 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -171,8 +171,7 @@ module Gem
# An English description of the error.
def wordy
- @source.uri.password = 'REDACTED' unless @source.uri.password.nil?
- "Unable to download data from #{@source.uri} - #{@error.message}"
+ "Unable to download data from #{Gem::Uri.new(@source.uri).redacted} - #{@error.message}"
end
##
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index e31ac8ede5..aaa3b8ce7b 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1556,8 +1556,8 @@ class Gem::Specification < Gem::BasicSpecification
# the gem.build_complete file is missing.
def build_extensions # :nodoc:
- return if default_gem?
return if extensions.empty?
+ return if default_gem?
return if File.exist? gem_build_complete_path
return if !File.writable?(base_dir)
return if !File.exist?(File.join(base_dir, 'extensions'))
@@ -2120,8 +2120,8 @@ class Gem::Specification < Gem::BasicSpecification
# probably want to build_extensions
def missing_extensions?
- return false if default_gem?
return false if extensions.empty?
+ return false if default_gem?
return false if File.exist? gem_build_complete_path
true
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index c30ec707d9..73bd31970c 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -381,7 +381,7 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
end
LAZY = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
- LAZY_PATTERN = /^FI XME|^TO DO/x.freeze
+ LAZY_PATTERN = /\AFI XME|\ATO DO/x.freeze
HOMEPAGE_URI_PATTERN = /\A[a-z][a-z\d+.-]*:/i.freeze
def validate_lazy_metadata
diff --git a/spec/bundler/bundler/source/git_spec.rb b/spec/bundler/bundler/source/git_spec.rb
index 6668b6e69a..ed6dc3cd29 100644
--- a/spec/bundler/bundler/source/git_spec.rb
+++ b/spec/bundler/bundler/source/git_spec.rb
@@ -24,5 +24,50 @@ RSpec.describe Bundler::Source::Git do
expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git"
end
end
+
+ context "when the source has a glob specifier" do
+ let(:glob) { "bar/baz/*.gemspec" }
+ let(:options) do
+ { "uri" => uri, "glob" => glob }
+ end
+
+ it "includes it" do
+ expect(subject.to_s).to eq "https://github.com/foo/bar.git (glob: bar/baz/*.gemspec)"
+ end
+ end
+
+ context "when the source has a reference" do
+ let(:git_proxy_stub) do
+ instance_double(Bundler::Source::Git::GitProxy, :revision => "123abc", :branch => "v1.0.0")
+ end
+ let(:options) do
+ { "uri" => uri, "ref" => "v1.0.0" }
+ end
+
+ before do
+ allow(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub)
+ end
+
+ it "includes it" do
+ expect(subject.to_s).to eq "https://github.com/foo/bar.git (at v1.0.0@123abc)"
+ end
+ end
+
+ context "when the source has both reference and glob specifiers" do
+ let(:git_proxy_stub) do
+ instance_double(Bundler::Source::Git::GitProxy, :revision => "123abc", :branch => "v1.0.0")
+ end
+ let(:options) do
+ { "uri" => uri, "ref" => "v1.0.0", "glob" => "gems/foo/*.gemspec" }
+ end
+
+ before do
+ allow(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub)
+ end
+
+ it "includes both" do
+ expect(subject.to_s).to eq "https://github.com/foo/bar.git (at v1.0.0@123abc, glob: gems/foo/*.gemspec)"
+ end
+ end
end
end
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index a01d8b0aa8..0d84153245 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -456,7 +456,7 @@ RSpec.describe "bundle gem" do
it "sets a minimum ruby version" do
bundle "gem #{gem_name}"
- expect(generated_gemspec.required_ruby_version).to eq(Gem::Requirement.new(Gem.ruby_version < Gem::Version.new("2.4.a") ? ">= 2.3.0" : ">= 2.4.0"))
+ expect(generated_gemspec.required_ruby_version.to_s).to start_with(">=")
end
it "requires the version file" do
diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb
index aaf8c74894..0ad5239128 100644
--- a/spec/bundler/support/hax.rb
+++ b/spec/bundler/support/hax.rb
@@ -9,7 +9,10 @@ module Gem
Gem.ruby = ENV["RUBY"]
end
- @default_dir = ENV["BUNDLER_GEM_DEFAULT_DIR"] if ENV["BUNDLER_GEM_DEFAULT_DIR"]
+ if ENV["BUNDLER_GEM_DEFAULT_DIR"]
+ @default_dir = ENV["BUNDLER_GEM_DEFAULT_DIR"]
+ @default_specifications_dir = nil
+ end
if ENV["BUNDLER_SPEC_PLATFORM"]
class Platform
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 9de716ff35..a7272bc019 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -275,7 +275,14 @@ module Spec
end
def rubocop_gemfile_basename
- source_root.join("tool/bundler/#{RUBY_VERSION.start_with?("2.3") ? "rubocop23_gems.rb" : "rubocop_gems.rb"}")
+ filename = if RUBY_VERSION.start_with?("2.3")
+ "rubocop23_gems"
+ elsif RUBY_VERSION.start_with?("2.4")
+ "rubocop24_gems"
+ else
+ "rubocop_gems"
+ end
+ source_root.join("tool/bundler/#{filename}.rb")
end
extend self
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index fd2763db41..ce05c9cf30 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -398,6 +398,7 @@ class Gem::TestCase < Test::Unit::TestCase
ENV['GEM_PRIVATE_KEY_PASSPHRASE'] = PRIVATE_KEY_PASSPHRASE
+ Gem.instance_variable_set(:@default_specifications_dir, nil)
if Gem.java_platform?
@orig_default_gem_home = RbConfig::CONFIG['default_gem_home']
RbConfig::CONFIG['default_gem_home'] = @gemhome
@@ -481,6 +482,7 @@ class Gem::TestCase < Test::Unit::TestCase
RbConfig::CONFIG['bindir'] = @orig_bindir
+ Gem.instance_variable_set :@default_specifications_dir, nil
if Gem.java_platform?
RbConfig::CONFIG['default_gem_home'] = @orig_default_gem_home
else
diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb
index 0b1472c0c6..816407781d 100644
--- a/test/rubygems/test_gem_source_fetch_problem.rb
+++ b/test/rubygems/test_gem_source_fetch_problem.rb
@@ -23,4 +23,14 @@ class TestGemSourceFetchProblem < Gem::TestCase
refute_match sf.wordy, 'secret'
end
+
+ def test_source_password_no_redacted
+ source = Gem::Source.new 'https://username:secret@gemsource.com'
+ error = RuntimeError.new 'test'
+
+ sf = Gem::SourceFetchProblem.new source, error
+ sf.wordy
+
+ assert_match 'secret', source.uri.to_s
+ end
end
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 782ae0380f..336fcf000e 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -2795,6 +2795,20 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
assert_nothing_raised do
@a1.validate
end
+
+ # Adding #{f} at the start of the second or later line should be fine.
+ @a1.description = "(some description)\n#{f}"
+
+ assert_nothing_raised do
+ @a1.validate
+ end
+
+ # Adding #{t} at the start of the second or later line should be fine.
+ @a1.description = "(some description)\n#{t}"
+
+ assert_nothing_raised do
+ @a1.validate
+ end
end
end
diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock
index 6804d112e8..2389416d86 100644
--- a/tool/bundler/rubocop_gems.rb.lock
+++ b/tool/bundler/rubocop_gems.rb.lock
@@ -4,12 +4,12 @@ GEM
ast (2.4.2)
diff-lcs (1.4.4)
minitest (5.14.4)
- parallel (1.19.2)
- parser (3.0.1.0)
+ parallel (1.21.0)
+ parser (3.0.2.0)
ast (~> 2.4.1)
- power_assert (2.0.0)
+ power_assert (2.0.1)
rainbow (3.0.0)
- rake (13.0.3)
+ rake (13.0.6)
rake-compiler (1.1.1)
rake
regexp_parser (2.1.1)
@@ -27,25 +27,26 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
- rubocop (1.12.1)
+ rubocop (1.21.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
- rubocop-ast (>= 1.2.0, < 2.0)
+ rubocop-ast (>= 1.9.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.4.1)
- parser (>= 2.7.1.5)
+ rubocop-ast (1.11.0)
+ parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
- test-unit (3.4.0)
+ test-unit (3.4.7)
power_assert
- unicode-display_width (2.0.0)
+ unicode-display_width (2.1.0)
PLATFORMS
arm64-darwin-20
universal-java-11
+ x86_64-darwin-19
x86_64-linux
DEPENDENCIES
@@ -57,4 +58,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
- 2.2.28
+ 2.2.29
diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock
index d232e5bbd8..533838d870 100644
--- a/tool/bundler/test_gems.rb.lock
+++ b/tool/bundler/test_gems.rb.lock
@@ -40,4 +40,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
- 2.2.28
+ 2.2.29