bundler 2.2.3 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -2
- data/bundler.gemspec +1 -1
- data/lib/bundler.rb +0 -1
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/cli.rb +3 -5
- data/lib/bundler/cli/cache.rb +1 -0
- data/lib/bundler/cli/gem.rb +14 -0
- data/lib/bundler/compact_index_client/updater.rb +0 -8
- data/lib/bundler/definition.rb +17 -27
- data/lib/bundler/dep_proxy.rb +15 -8
- data/lib/bundler/feature_flag.rb +0 -1
- data/lib/bundler/fetcher.rb +0 -1
- data/lib/bundler/gem_helper.rb +9 -7
- data/lib/bundler/gem_version_promoter.rb +2 -2
- data/lib/bundler/index.rb +6 -5
- data/lib/bundler/installer.rb +0 -17
- data/lib/bundler/installer/standalone.rb +15 -0
- data/lib/bundler/lazy_specification.rb +9 -18
- data/{man → lib/bundler/man}/bundle-add.1 +1 -1
- data/{man → lib/bundler/man}/bundle-binstubs.1 +1 -1
- data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
- data/{man → lib/bundler/man}/bundle-check.1 +1 -1
- data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
- data/{man → lib/bundler/man}/bundle-config.1 +4 -4
- data/lib/bundler/man/bundle-config.1.ronn +3 -3
- data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
- data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
- data/{man → lib/bundler/man}/bundle-gem.1 +1 -1
- data/{man → lib/bundler/man}/bundle-info.1 +1 -1
- data/{man → lib/bundler/man}/bundle-init.1 +1 -1
- data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
- data/{man → lib/bundler/man}/bundle-install.1 +1 -1
- data/{man → lib/bundler/man}/bundle-list.1 +1 -1
- data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
- data/{man → lib/bundler/man}/bundle-open.1 +1 -1
- data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
- data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
- data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
- data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
- data/{man → lib/bundler/man}/bundle-show.1 +1 -1
- data/{man → lib/bundler/man}/bundle-update.1 +1 -1
- data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
- data/{man → lib/bundler/man}/bundle.1 +1 -1
- data/{man → lib/bundler/man}/gemfile.5 +1 -1
- data/{man → lib/bundler/man}/index.txt +0 -0
- data/lib/bundler/resolver.rb +82 -43
- data/lib/bundler/resolver/spec_group.rb +56 -44
- data/lib/bundler/rubygems_ext.rb +16 -0
- data/lib/bundler/settings.rb +1 -1
- data/lib/bundler/shared_helpers.rb +2 -2
- data/lib/bundler/source/git.rb +19 -17
- data/lib/bundler/source/git/git_proxy.rb +54 -49
- data/lib/bundler/source/path/installer.rb +2 -0
- data/lib/bundler/source/rubygems.rb +10 -2
- data/lib/bundler/source_list.rb +2 -4
- data/lib/bundler/spec_set.rb +5 -4
- data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/lib/bundler/templates/newgem/rubocop.yml.tt +3 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +2 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +11 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +11 -7
- data/lib/bundler/vendor/thor/lib/thor.rb +5 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
- data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/version.rb +1 -1
- metadata +30 -29
|
@@ -3,28 +3,37 @@
|
|
|
3
3
|
module Bundler
|
|
4
4
|
class Resolver
|
|
5
5
|
class SpecGroup
|
|
6
|
-
include GemHelpers
|
|
7
|
-
|
|
8
6
|
attr_accessor :name, :version, :source
|
|
9
|
-
attr_accessor :
|
|
7
|
+
attr_accessor :activated_platforms
|
|
8
|
+
|
|
9
|
+
def self.create_for(specs, all_platforms, specific_platform)
|
|
10
|
+
specific_platform_specs = specs[specific_platform]
|
|
11
|
+
return unless specific_platform_specs.any?
|
|
12
|
+
|
|
13
|
+
platforms = all_platforms.select {|p| specs[p].any? }
|
|
14
|
+
|
|
15
|
+
new(specific_platform_specs.first, specs, platforms)
|
|
16
|
+
end
|
|
10
17
|
|
|
11
|
-
def initialize(
|
|
12
|
-
@
|
|
13
|
-
raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
|
|
18
|
+
def initialize(exemplary_spec, specs, relevant_platforms)
|
|
19
|
+
@exemplary_spec = exemplary_spec
|
|
14
20
|
@name = exemplary_spec.name
|
|
15
21
|
@version = exemplary_spec.version
|
|
16
22
|
@source = exemplary_spec.source
|
|
17
23
|
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
21
|
-
|
|
24
|
+
@all_platforms = relevant_platforms
|
|
25
|
+
@activated_platforms = relevant_platforms
|
|
26
|
+
@dependencies = Hash.new do |dependencies, platforms|
|
|
27
|
+
dependencies[platforms] = dependencies_for(platforms)
|
|
22
28
|
end
|
|
23
|
-
@
|
|
29
|
+
@partitioned_dependency_names = Hash.new do |partitioned_dependency_names, platforms|
|
|
30
|
+
partitioned_dependency_names[platforms] = partitioned_dependency_names_for(platforms)
|
|
31
|
+
end
|
|
32
|
+
@specs = specs
|
|
24
33
|
end
|
|
25
34
|
|
|
26
35
|
def to_specs
|
|
27
|
-
|
|
36
|
+
activated_platforms.map do |p|
|
|
28
37
|
specs = @specs[p]
|
|
29
38
|
next unless specs.any?
|
|
30
39
|
|
|
@@ -36,18 +45,12 @@ module Bundler
|
|
|
36
45
|
end.flatten.compact.uniq
|
|
37
46
|
end
|
|
38
47
|
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
return unless platforms.any?
|
|
42
|
-
|
|
43
|
-
copied_sg = self.class.new(@all_specs)
|
|
44
|
-
copied_sg.ignores_bundler_dependencies = @ignores_bundler_dependencies
|
|
45
|
-
copied_sg.activated_platforms = platforms
|
|
46
|
-
copied_sg
|
|
48
|
+
def activate_platform!(platform)
|
|
49
|
+
self.activated_platforms = [platform]
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def
|
|
50
|
-
@
|
|
52
|
+
def activate_all_platforms!
|
|
53
|
+
self.activated_platforms = @all_platforms
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
def to_s
|
|
@@ -56,11 +59,11 @@ module Bundler
|
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
def dependencies_for_activated_platforms
|
|
59
|
-
dependencies
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
@dependencies[activated_platforms]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def partitioned_dependency_names_for_activated_platforms
|
|
66
|
+
@partitioned_dependency_names[activated_platforms]
|
|
64
67
|
end
|
|
65
68
|
|
|
66
69
|
def ==(other)
|
|
@@ -86,34 +89,43 @@ module Bundler
|
|
|
86
89
|
protected
|
|
87
90
|
|
|
88
91
|
def sorted_activated_platforms
|
|
89
|
-
|
|
92
|
+
activated_platforms.sort_by(&:to_s)
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
private
|
|
93
96
|
|
|
94
|
-
def
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
def dependencies_for(platforms)
|
|
98
|
+
platforms.map do |platform|
|
|
99
|
+
__dependencies(platform) + metadata_dependencies(platform)
|
|
100
|
+
end.flatten
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def partitioned_dependency_names_for(platforms)
|
|
104
|
+
return @dependencies[platforms].map(&:name), [] if platforms.size == 1
|
|
105
|
+
|
|
106
|
+
@dependencies[platforms].partition do |dep_proxy|
|
|
107
|
+
@dependencies[platforms].count {|dp| dp.dep == dep_proxy.dep } == platforms.size
|
|
108
|
+
end.map {|deps| deps.map(&:name) }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def __dependencies(platform)
|
|
112
|
+
dependencies = []
|
|
113
|
+
@specs[platform].first.dependencies.each do |dep|
|
|
114
|
+
next if dep.type == :development
|
|
115
|
+
dependencies << DepProxy.get_proxy(dep, platform)
|
|
106
116
|
end
|
|
117
|
+
dependencies
|
|
107
118
|
end
|
|
108
119
|
|
|
109
|
-
def metadata_dependencies(
|
|
110
|
-
|
|
120
|
+
def metadata_dependencies(platform)
|
|
121
|
+
spec = @specs[platform].first
|
|
122
|
+
return [] unless spec.is_a?(Gem::Specification)
|
|
111
123
|
dependencies = []
|
|
112
124
|
if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
|
|
113
|
-
dependencies << DepProxy.
|
|
125
|
+
dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
|
|
114
126
|
end
|
|
115
127
|
if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
|
|
116
|
-
dependencies << DepProxy.
|
|
128
|
+
dependencies << DepProxy.get_proxy(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
|
|
117
129
|
end
|
|
118
130
|
dependencies
|
|
119
131
|
end
|
data/lib/bundler/rubygems_ext.rb
CHANGED
|
@@ -158,6 +158,22 @@ module Gem
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
+
if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash
|
|
162
|
+
class Requirement
|
|
163
|
+
module CorrectHashForLambdaOperator
|
|
164
|
+
def hash
|
|
165
|
+
if requirements.any? {|r| r.first == "~>" }
|
|
166
|
+
requirements.map {|r| r.first == "~>" ? [r[0], r[1].to_s] : r }.sort.hash
|
|
167
|
+
else
|
|
168
|
+
super
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
prepend CorrectHashForLambdaOperator
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
161
177
|
class Platform
|
|
162
178
|
JAVA = Gem::Platform.new("java") unless defined?(JAVA)
|
|
163
179
|
MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
|
data/lib/bundler/settings.rb
CHANGED
|
@@ -7,7 +7,6 @@ module Bundler
|
|
|
7
7
|
autoload :Validator, File.expand_path("settings/validator", __dir__)
|
|
8
8
|
|
|
9
9
|
BOOL_KEYS = %w[
|
|
10
|
-
allow_bundler_dependency_conflicts
|
|
11
10
|
allow_deployment_source_credential_changes
|
|
12
11
|
allow_offline_install
|
|
13
12
|
auto_clean_without_path
|
|
@@ -20,6 +19,7 @@ module Bundler
|
|
|
20
19
|
disable_checksum_validation
|
|
21
20
|
disable_exec_load
|
|
22
21
|
disable_local_branch_check
|
|
22
|
+
disable_local_revision_check
|
|
23
23
|
disable_multisource
|
|
24
24
|
disable_shared_gems
|
|
25
25
|
disable_version_check
|
|
@@ -194,11 +194,11 @@ module Bundler
|
|
|
194
194
|
return @md5_available if defined?(@md5_available)
|
|
195
195
|
@md5_available = begin
|
|
196
196
|
require "openssl"
|
|
197
|
-
OpenSSL::Digest.digest("MD5", "")
|
|
197
|
+
::OpenSSL::Digest.digest("MD5", "")
|
|
198
198
|
true
|
|
199
199
|
rescue LoadError
|
|
200
200
|
true
|
|
201
|
-
rescue OpenSSL::Digest::DigestError
|
|
201
|
+
rescue ::OpenSSL::Digest::DigestError
|
|
202
202
|
false
|
|
203
203
|
end
|
|
204
204
|
end
|
data/lib/bundler/source/git.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Bundler
|
|
|
22
22
|
@uri = options["uri"] || ""
|
|
23
23
|
@safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
|
|
24
24
|
@branch = options["branch"]
|
|
25
|
-
@ref = options["ref"] || options["branch"] || options["tag"]
|
|
25
|
+
@ref = options["ref"] || options["branch"] || options["tag"]
|
|
26
26
|
@submodules = options["submodules"]
|
|
27
27
|
@name = options["name"]
|
|
28
28
|
@version = options["version"].to_s.strip.gsub("-", ".pre.")
|
|
@@ -60,25 +60,27 @@ module Bundler
|
|
|
60
60
|
alias_method :==, :eql?
|
|
61
61
|
|
|
62
62
|
def to_s
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
begin
|
|
64
|
+
at = if local?
|
|
65
|
+
path
|
|
66
|
+
elsif user_ref = options["ref"]
|
|
67
|
+
if ref =~ /\A[a-z0-9]{4,}\z/i
|
|
68
|
+
shortref_for_display(user_ref)
|
|
69
|
+
else
|
|
70
|
+
user_ref
|
|
71
|
+
end
|
|
72
|
+
elsif ref
|
|
73
|
+
ref
|
|
68
74
|
else
|
|
69
|
-
|
|
75
|
+
git_proxy.branch
|
|
70
76
|
end
|
|
71
|
-
else
|
|
72
|
-
ref
|
|
73
|
-
end
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
end
|
|
78
|
+
rev = " (at #{at}@#{shortref_for_display(revision)})"
|
|
79
|
+
rescue GitError
|
|
80
|
+
""
|
|
81
|
+
end
|
|
80
82
|
|
|
81
|
-
"#{@safe_uri}
|
|
83
|
+
"#{@safe_uri}#{rev}"
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
def name
|
|
@@ -146,7 +148,7 @@ module Bundler
|
|
|
146
148
|
|
|
147
149
|
changed = cached_revision && cached_revision != git_proxy.revision
|
|
148
150
|
|
|
149
|
-
if changed && !@unlocked && !git_proxy.contains?(cached_revision)
|
|
151
|
+
if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(cached_revision)
|
|
150
152
|
raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
|
|
151
153
|
"but the current branch in your local override for #{name} does not contain such commit. " \
|
|
152
154
|
"Please make sure your branch is up to date."
|
|
@@ -17,7 +17,7 @@ module Bundler
|
|
|
17
17
|
class GitNotAllowedError < GitError
|
|
18
18
|
def initialize(command)
|
|
19
19
|
msg = String.new
|
|
20
|
-
msg << "Bundler is trying to run
|
|
20
|
+
msg << "Bundler is trying to run `#{command}` at runtime. You probably need to run `bundle install`. However, "
|
|
21
21
|
msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md "
|
|
22
22
|
msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
|
|
23
23
|
super msg
|
|
@@ -27,11 +27,11 @@ module Bundler
|
|
|
27
27
|
class GitCommandError < GitError
|
|
28
28
|
attr_reader :command
|
|
29
29
|
|
|
30
|
-
def initialize(command, path,
|
|
30
|
+
def initialize(command, path, extra_info = nil)
|
|
31
31
|
@command = command
|
|
32
32
|
|
|
33
33
|
msg = String.new
|
|
34
|
-
msg << "Git error: command
|
|
34
|
+
msg << "Git error: command `#{command}` in directory #{path} has failed."
|
|
35
35
|
msg << "\n#{extra_info}" if extra_info
|
|
36
36
|
msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path.exist?
|
|
37
37
|
super msg
|
|
@@ -39,9 +39,9 @@ module Bundler
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
class MissingGitRevisionError < GitCommandError
|
|
42
|
-
def initialize(command,
|
|
42
|
+
def initialize(command, destination_path, ref, repo)
|
|
43
43
|
msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
|
|
44
|
-
super command,
|
|
44
|
+
super command, destination_path, msg
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -67,13 +67,13 @@ module Bundler
|
|
|
67
67
|
|
|
68
68
|
def branch
|
|
69
69
|
@branch ||= allowed_with_path do
|
|
70
|
-
git("rev-parse --abbrev-ref HEAD", :dir => path).strip
|
|
70
|
+
git("rev-parse", "--abbrev-ref", "HEAD", :dir => path).strip
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def contains?(commit)
|
|
75
75
|
allowed_with_path do
|
|
76
|
-
result, status = git_null("branch --contains
|
|
76
|
+
result, status = git_null("branch", "--contains", commit, :dir => path)
|
|
77
77
|
status.success? && result =~ /^\* (.*)$/
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -88,20 +88,22 @@ module Bundler
|
|
|
88
88
|
|
|
89
89
|
def checkout
|
|
90
90
|
return if path.exist? && has_revision_cached?
|
|
91
|
-
extra_ref = "#{
|
|
91
|
+
extra_ref = "#{ref}:#{ref}" if ref && ref.start_with?("refs/")
|
|
92
92
|
|
|
93
93
|
Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
|
|
94
94
|
|
|
95
|
+
configured_uri = configured_uri_for(uri).to_s
|
|
96
|
+
|
|
95
97
|
unless path.exist?
|
|
96
98
|
SharedHelpers.filesystem_access(path.dirname) do |p|
|
|
97
99
|
FileUtils.mkdir_p(p)
|
|
98
100
|
end
|
|
99
|
-
git_retry
|
|
101
|
+
git_retry "clone", configured_uri, path.to_s, "--bare", "--no-hardlinks", "--quiet"
|
|
100
102
|
return unless extra_ref
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
with_path do
|
|
104
|
-
git_retry
|
|
106
|
+
git_retry(*["fetch", "--force", "--quiet", "--tags", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
109
|
|
|
@@ -115,7 +117,7 @@ module Bundler
|
|
|
115
117
|
SharedHelpers.filesystem_access(destination) do |p|
|
|
116
118
|
FileUtils.rm_rf(p)
|
|
117
119
|
end
|
|
118
|
-
git_retry
|
|
120
|
+
git_retry "clone", "--no-checkout", "--quiet", path.to_s, destination.to_s
|
|
119
121
|
File.chmod(((File.stat(destination).mode | 0o777) & ~File.umask), destination)
|
|
120
122
|
rescue Errno::EEXIST => e
|
|
121
123
|
file_path = e.message[%r{.*?((?:[a-zA-Z]:)?/.*)}, 1]
|
|
@@ -125,56 +127,59 @@ module Bundler
|
|
|
125
127
|
end
|
|
126
128
|
end
|
|
127
129
|
# method 2
|
|
128
|
-
git_retry
|
|
130
|
+
git_retry "fetch", "--force", "--quiet", "--tags", path.to_s, :dir => destination
|
|
129
131
|
|
|
130
132
|
begin
|
|
131
|
-
git "reset --hard
|
|
133
|
+
git "reset", "--hard", @revision, :dir => destination
|
|
132
134
|
rescue GitCommandError => e
|
|
133
|
-
raise MissingGitRevisionError.new(e.command,
|
|
135
|
+
raise MissingGitRevisionError.new(e.command, destination, @revision, URICredentialsFilter.credential_filtered_uri(uri))
|
|
134
136
|
end
|
|
135
137
|
|
|
136
138
|
if submodules
|
|
137
|
-
git_retry "submodule update --init --recursive", :dir => destination
|
|
139
|
+
git_retry "submodule", "update", "--init", "--recursive", :dir => destination
|
|
138
140
|
elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
|
|
139
141
|
inner_command = "git -C $toplevel submodule deinit --force $sm_path"
|
|
140
|
-
|
|
141
|
-
git_retry "submodule foreach --quiet \"#{inner_command}\"", :dir => destination
|
|
142
|
+
git_retry "submodule", "foreach", "--quiet", inner_command, :dir => destination
|
|
142
143
|
end
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
private
|
|
146
147
|
|
|
147
|
-
def git_null(command, dir:
|
|
148
|
+
def git_null(*command, dir: nil)
|
|
148
149
|
check_allowed(command)
|
|
149
150
|
|
|
150
151
|
out, status = SharedHelpers.with_clean_git_env do
|
|
151
|
-
capture_and_ignore_stderr(
|
|
152
|
+
capture_and_ignore_stderr(*capture3_args_for(command, dir))
|
|
152
153
|
end
|
|
153
154
|
|
|
154
155
|
[URICredentialsFilter.credential_filtered_string(out, uri), status]
|
|
155
156
|
end
|
|
156
157
|
|
|
157
|
-
def git_retry(command, dir:
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
def git_retry(*command, dir: nil)
|
|
159
|
+
command_with_no_credentials = check_allowed(command)
|
|
160
|
+
|
|
161
|
+
Bundler::Retry.new("`#{command_with_no_credentials}` at #{dir || SharedHelpers.pwd}").attempts do
|
|
162
|
+
git(*command, :dir => dir)
|
|
160
163
|
end
|
|
161
164
|
end
|
|
162
165
|
|
|
163
|
-
def git(command, dir:
|
|
166
|
+
def git(*command, dir: nil)
|
|
164
167
|
command_with_no_credentials = check_allowed(command)
|
|
165
168
|
|
|
166
169
|
out, status = SharedHelpers.with_clean_git_env do
|
|
167
|
-
capture_and_filter_stderr(
|
|
170
|
+
capture_and_filter_stderr(*capture3_args_for(command, dir))
|
|
168
171
|
end
|
|
169
172
|
|
|
170
|
-
|
|
173
|
+
filtered_out = URICredentialsFilter.credential_filtered_string(out, uri)
|
|
174
|
+
|
|
175
|
+
raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, filtered_out) unless status.success?
|
|
171
176
|
|
|
172
|
-
|
|
177
|
+
filtered_out
|
|
173
178
|
end
|
|
174
179
|
|
|
175
180
|
def has_revision_cached?
|
|
176
181
|
return unless @revision
|
|
177
|
-
with_path { git("cat-file -e
|
|
182
|
+
with_path { git("cat-file", "-e", @revision, :dir => path) }
|
|
178
183
|
true
|
|
179
184
|
rescue GitError
|
|
180
185
|
false
|
|
@@ -186,24 +191,10 @@ module Bundler
|
|
|
186
191
|
|
|
187
192
|
def find_local_revision
|
|
188
193
|
allowed_with_path do
|
|
189
|
-
git("rev-parse --verify
|
|
194
|
+
git("rev-parse", "--verify", ref || "HEAD", :dir => path).strip
|
|
190
195
|
end
|
|
191
196
|
rescue GitCommandError => e
|
|
192
|
-
raise MissingGitRevisionError.new(e.command, path,
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
# Escape the URI for git commands
|
|
196
|
-
def uri_escaped_with_configured_credentials
|
|
197
|
-
remote = configured_uri_for(uri)
|
|
198
|
-
if Bundler::WINDOWS
|
|
199
|
-
# Windows quoting requires double quotes only, with double quotes
|
|
200
|
-
# inside the string escaped by being doubled.
|
|
201
|
-
'"' + remote.gsub('"') { '""' } + '"'
|
|
202
|
-
else
|
|
203
|
-
# Bash requires single quoted strings, with the single quotes escaped
|
|
204
|
-
# by ending the string, escaping the quote, and restarting the string.
|
|
205
|
-
"'" + remote.gsub("'") { "'\\''" } + "'"
|
|
206
|
-
end
|
|
197
|
+
raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
|
|
207
198
|
end
|
|
208
199
|
|
|
209
200
|
# Adds credentials to the URI as Fetcher#configured_uri_for does
|
|
@@ -233,23 +224,37 @@ module Bundler
|
|
|
233
224
|
end
|
|
234
225
|
|
|
235
226
|
def check_allowed(command)
|
|
236
|
-
command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command, uri)
|
|
227
|
+
command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
|
|
237
228
|
raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
|
|
238
229
|
command_with_no_credentials
|
|
239
230
|
end
|
|
240
231
|
|
|
241
|
-
def capture_and_filter_stderr(
|
|
232
|
+
def capture_and_filter_stderr(*cmd)
|
|
242
233
|
require "open3"
|
|
243
|
-
return_value, captured_err, status = Open3.capture3(cmd
|
|
244
|
-
Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri)
|
|
234
|
+
return_value, captured_err, status = Open3.capture3(*cmd)
|
|
235
|
+
Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) unless captured_err.empty?
|
|
245
236
|
[return_value, status]
|
|
246
237
|
end
|
|
247
238
|
|
|
248
|
-
def capture_and_ignore_stderr(cmd
|
|
239
|
+
def capture_and_ignore_stderr(*cmd)
|
|
249
240
|
require "open3"
|
|
250
|
-
return_value, _, status = Open3.capture3(cmd
|
|
241
|
+
return_value, _, status = Open3.capture3(*cmd)
|
|
251
242
|
[return_value, status]
|
|
252
243
|
end
|
|
244
|
+
|
|
245
|
+
def capture3_args_for(cmd, dir)
|
|
246
|
+
return ["git", *cmd] unless dir
|
|
247
|
+
|
|
248
|
+
if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
|
|
249
|
+
["git", "-C", dir.to_s, *cmd]
|
|
250
|
+
else
|
|
251
|
+
["git", *cmd, { :chdir => dir.to_s }]
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def supports_minus_c?
|
|
256
|
+
@supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
|
|
257
|
+
end
|
|
253
258
|
end
|
|
254
259
|
end
|
|
255
260
|
end
|