summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-11-22 19:24:53 +0000
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-13 20:07:17 +0100
commitfdc0c230541883270d0c842222f802c478f32707 (patch)
treef8dba504c6caa3c4b7ba349318bafead1892e2df
parentfabf317e41c5998dca4ebf475101cd3eec177e5f (diff)
downloadbundler-fdc0c230541883270d0c842222f802c478f32707.tar.gz
Merge #7450
7450: Backport ruby-core changes r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that we haven't incorporated recent fixes for integration in ruby-core. ### What is your fix for the problem, implemented in this PR? My fix is to cherry-pick the fixes. Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com> Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> (cherry picked from commit dbcfed3fe08a6d38455d01a6783fffa0e13edf94)
-rw-r--r--spec/commands/version_spec.rb12
-rw-r--r--spec/support/path.rb12
2 files changed, 21 insertions, 3 deletions
diff --git a/spec/commands/version_spec.rb b/spec/commands/version_spec.rb
index 66c7930397..8eecd9c53e 100644
--- a/spec/commands/version_spec.rb
+++ b/spec/commands/version_spec.rb
@@ -1,6 +1,14 @@
# frozen_string_literal: true
+require_relative "../support/path"
+
RSpec.describe "bundle version" do
+ if Spec::Path.ruby_core?
+ COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/.freeze
+ else
+ COMMIT_HASH = /[a-fA-F0-9]{7,}/.freeze
+ end
+
context "with -v" do
it "outputs the version", :bundler => "< 3" do
bundle! "-v"
@@ -28,12 +36,12 @@ RSpec.describe "bundle version" do
context "with version" do
it "outputs the version with build metadata", :bundler => "< 3" do
bundle! "version"
- expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/)
+ expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/)
end
it "outputs the version with build metadata", :bundler => "3" do
bundle! "version"
- expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/)
+ expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/)
end
end
end
diff --git a/spec/support/path.rb b/spec/support/path.rb
index cc5aebb01b..4b3941b70f 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -30,14 +30,23 @@ module Spec
end
def tracked_files
+ if root != `git rev-parse --show-toplevel`
+ skip "not in git working directory"
+ end
@tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z`
end
def shipped_files
+ if root != `git rev-parse --show-toplevel`
+ skip "not in git working directory"
+ end
@shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec`
end
def lib_tracked_files
+ if root != `git rev-parse --show-toplevel`
+ skip "not in git working directory"
+ end
@lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
end
@@ -150,7 +159,8 @@ module Spec
def with_root_gemspec
if ruby_core?
root_gemspec = root.join("bundler.gemspec")
- spec = Gem::Specification.load(gemspec.to_s)
+ # Dir.chdir(root) for Dir.glob in gemspec
+ spec = Dir.chdir(root) { Gem::Specification.load(gemspec.to_s) }
spec.bindir = "libexec"
File.open(root_gemspec.to_s, "w") {|f| f.write spec.to_ruby }
yield(root_gemspec)