mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Add glob infomation to Bundler::Source::Git#to_s
The glob information was not specified in the string representation for a source, which led to non-deterministic behaviour when generating the lockfile, since sources are sorted by this value. https://github.com/rubygems/rubygems/commit/493b880abc
This commit is contained in:
parent
06c3e80611
commit
ad92651d64
2 changed files with 64 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue