bundler 2.1.4 → 2.2.17
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1774 -1430
- data/README.md +6 -8
- data/bundler.gemspec +4 -4
- data/exe/bundle +3 -0
- data/lib/bundler.rb +33 -9
- data/lib/bundler/build_metadata.rb +3 -11
- data/lib/bundler/cli.rb +59 -23
- data/lib/bundler/cli/add.rb +1 -1
- data/lib/bundler/cli/binstubs.rb +6 -2
- data/lib/bundler/cli/cache.rb +2 -7
- data/lib/bundler/cli/clean.rb +1 -1
- data/lib/bundler/cli/common.rb +29 -2
- data/lib/bundler/cli/console.rb +1 -1
- data/lib/bundler/cli/doctor.rb +1 -1
- data/lib/bundler/cli/exec.rb +4 -4
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +129 -28
- data/lib/bundler/cli/info.rb +15 -4
- data/lib/bundler/cli/init.rb +2 -2
- data/lib/bundler/cli/inject.rb +1 -1
- data/lib/bundler/cli/install.rb +13 -11
- data/lib/bundler/cli/issue.rb +2 -2
- data/lib/bundler/cli/list.rb +12 -10
- data/lib/bundler/cli/outdated.rb +88 -67
- data/lib/bundler/cli/plugin.rb +10 -0
- data/lib/bundler/cli/pristine.rb +5 -0
- data/lib/bundler/cli/show.rb +1 -1
- data/lib/bundler/cli/update.rb +3 -1
- data/lib/bundler/compact_index_client.rb +1 -1
- data/lib/bundler/compact_index_client/cache.rb +6 -14
- data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
- data/lib/bundler/compact_index_client/updater.rb +13 -17
- data/lib/bundler/current_ruby.rb +1 -0
- data/lib/bundler/definition.rb +121 -131
- data/lib/bundler/dep_proxy.rb +16 -9
- data/lib/bundler/dependency.rb +3 -10
- data/lib/bundler/dsl.rb +40 -33
- data/lib/bundler/endpoint_specification.rb +1 -1
- data/lib/bundler/env.rb +1 -1
- data/lib/bundler/environment_preserver.rb +26 -2
- data/lib/bundler/errors.rb +1 -0
- data/lib/bundler/feature_flag.rb +0 -5
- data/lib/bundler/fetcher.rb +5 -4
- data/lib/bundler/fetcher/base.rb +1 -1
- data/lib/bundler/fetcher/compact_index.rb +1 -1
- data/lib/bundler/fetcher/downloader.rb +9 -5
- data/lib/bundler/fetcher/index.rb +3 -4
- data/lib/bundler/friendly_errors.rb +22 -13
- data/lib/bundler/gem_helper.rb +51 -18
- data/lib/bundler/gem_helpers.rb +36 -25
- data/lib/bundler/gem_version_promoter.rb +4 -4
- data/lib/bundler/graph.rb +1 -1
- data/lib/bundler/index.rb +12 -7
- data/lib/bundler/injector.rb +23 -5
- data/lib/bundler/inline.rb +3 -2
- data/lib/bundler/installer.rb +37 -49
- data/lib/bundler/installer/gem_installer.rb +3 -3
- data/lib/bundler/installer/parallel_installer.rb +46 -25
- data/lib/bundler/installer/standalone.rb +17 -2
- data/lib/bundler/lazy_specification.rb +45 -25
- data/lib/bundler/lockfile_generator.rb +1 -1
- data/lib/bundler/lockfile_parser.rb +4 -14
- data/lib/bundler/man/.document +1 -0
- data/{man → lib/bundler/man}/bundle-add.1 +1 -1
- data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
- data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
- data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
- data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-check.1 +1 -1
- data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
- data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-config.1 +42 -34
- data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +51 -43
- data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
- data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
- data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-gem.1 +25 -3
- data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +30 -7
- data/{man → lib/bundler/man}/bundle-info.1 +1 -1
- data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-init.1 +1 -1
- data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
- data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-install.1 +30 -3
- data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
- data/{man → lib/bundler/man}/bundle-list.1 +7 -7
- data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
- data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
- data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-open.1 +1 -1
- data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
- data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
- data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
- data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
- data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-show.1 +1 -1
- data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-update.1 +1 -1
- data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
- data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle.1 +1 -1
- data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
- data/{man → lib/bundler/man}/gemfile.5 +4 -4
- data/{man → lib/bundler/man}/gemfile.5.ronn +4 -4
- data/{man → lib/bundler/man}/index.txt +0 -0
- data/lib/bundler/mirror.rb +2 -2
- data/lib/bundler/plugin.rb +33 -7
- data/lib/bundler/plugin/api/source.rb +8 -1
- data/lib/bundler/plugin/dsl.rb +1 -1
- data/lib/bundler/plugin/index.rb +10 -1
- data/lib/bundler/plugin/installer.rb +9 -11
- data/lib/bundler/plugin/installer/rubygems.rb +1 -1
- data/lib/bundler/plugin/source_list.rb +5 -1
- data/lib/bundler/psyched_yaml.rb +0 -15
- data/lib/bundler/remote_specification.rb +5 -2
- data/lib/bundler/resolver.rb +133 -77
- data/lib/bundler/resolver/spec_group.rb +75 -48
- data/lib/bundler/retry.rb +2 -2
- data/lib/bundler/ruby_version.rb +1 -1
- data/lib/bundler/rubygems_ext.rb +69 -9
- data/lib/bundler/rubygems_gem_installer.rb +50 -9
- data/lib/bundler/rubygems_integration.rb +25 -60
- data/lib/bundler/runtime.rb +4 -14
- data/lib/bundler/settings.rb +107 -54
- data/lib/bundler/shared_helpers.rb +3 -3
- data/lib/bundler/similarity_detector.rb +1 -1
- data/lib/bundler/source.rb +7 -1
- data/lib/bundler/source/git.rb +24 -22
- data/lib/bundler/source/git/git_proxy.rb +82 -80
- data/lib/bundler/source/metadata.rb +0 -4
- data/lib/bundler/source/path.rb +10 -4
- data/lib/bundler/source/path/installer.rb +10 -10
- data/lib/bundler/source/rubygems.rb +45 -24
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source_list.rb +31 -26
- data/lib/bundler/spec_set.rb +29 -17
- data/lib/bundler/stub_specification.rb +25 -7
- data/lib/bundler/templates/Gemfile +1 -1
- data/lib/bundler/templates/gems.rb +1 -1
- data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
- data/lib/bundler/templates/newgem/Gemfile.tt +9 -1
- data/lib/bundler/templates/newgem/README.md.tt +6 -5
- data/lib/bundler/templates/newgem/Rakefile.tt +19 -5
- data/lib/bundler/templates/newgem/bin/console.tt +1 -0
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +16 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +15 -7
- data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
- data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
- data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
- data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
- data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
- data/lib/bundler/ui/shell.rb +5 -5
- data/lib/bundler/uri_credentials_filter.rb +3 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +34 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
- data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
- data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
- 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/vendor/tmpdir/lib/tmpdir.rb +154 -0
- data/lib/bundler/vendored_persistent.rb +0 -7
- data/lib/bundler/vendored_tmpdir.rb +4 -0
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/worker.rb +1 -1
- data/lib/bundler/yaml_serializer.rb +1 -1
- metadata +71 -85
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
- data/man/bundle-add.1.txt +0 -58
- data/man/bundle-binstubs.1.txt +0 -48
- data/man/bundle-cache.1.txt +0 -78
- data/man/bundle-check.1.txt +0 -33
- data/man/bundle-clean.1.txt +0 -26
- data/man/bundle-config.1.txt +0 -528
- data/man/bundle-doctor.1.txt +0 -44
- data/man/bundle-exec.1.txt +0 -178
- data/man/bundle-gem.1.txt +0 -91
- data/man/bundle-info.1.txt +0 -21
- data/man/bundle-init.1.txt +0 -34
- data/man/bundle-inject.1.txt +0 -32
- data/man/bundle-install.1.txt +0 -401
- data/man/bundle-list.1.txt +0 -43
- data/man/bundle-lock.1.txt +0 -93
- data/man/bundle-open.1.txt +0 -29
- data/man/bundle-outdated.1.txt +0 -131
- data/man/bundle-platform.1.txt +0 -57
- data/man/bundle-pristine.1.txt +0 -44
- data/man/bundle-remove.1.txt +0 -34
- data/man/bundle-show.1.txt +0 -27
- data/man/bundle-update.1.txt +0 -390
- data/man/bundle-viz.1.txt +0 -39
- data/man/bundle.1.txt +0 -116
- data/man/gemfile.5.txt +0 -649
@@ -4,7 +4,19 @@ require_relative "vendored_thor"
|
|
4
4
|
|
5
5
|
module Bundler
|
6
6
|
module FriendlyErrors
|
7
|
-
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def enable!
|
10
|
+
@disabled = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def disabled?
|
14
|
+
@disabled
|
15
|
+
end
|
16
|
+
|
17
|
+
def disable!
|
18
|
+
@disabled = true
|
19
|
+
end
|
8
20
|
|
9
21
|
def log_error(error)
|
10
22
|
case error
|
@@ -23,13 +35,7 @@ module Bundler
|
|
23
35
|
Bundler.ui.error error.message
|
24
36
|
when LoadError
|
25
37
|
raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
|
26
|
-
Bundler.ui.error "\nCould not load OpenSSL."
|
27
|
-
Bundler.ui.warn <<-WARN, :wrap => true
|
28
|
-
You must recompile Ruby with OpenSSL support or change the sources in your \
|
29
|
-
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
|
30
|
-
using RVM are available at https://rvm.io/packages/openssl.
|
31
|
-
WARN
|
32
|
-
Bundler.ui.trace error
|
38
|
+
Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}\n#{error.backtrace.join("\n ")}"
|
33
39
|
when Interrupt
|
34
40
|
Bundler.ui.error "\nQuitting..."
|
35
41
|
Bundler.ui.trace error
|
@@ -57,7 +63,7 @@ module Bundler
|
|
57
63
|
end
|
58
64
|
|
59
65
|
def request_issue_report_for(e)
|
60
|
-
Bundler.ui.
|
66
|
+
Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, nil
|
61
67
|
--- ERROR REPORT TEMPLATE -------------------------------------------------------
|
62
68
|
# Error Report
|
63
69
|
|
@@ -82,7 +88,7 @@ module Bundler
|
|
82
88
|
|
83
89
|
I tried...
|
84
90
|
|
85
|
-
- **Have you read our issues document, https://github.com/
|
91
|
+
- **Have you read our issues document, https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md?**
|
86
92
|
|
87
93
|
...
|
88
94
|
|
@@ -100,13 +106,13 @@ module Bundler
|
|
100
106
|
|
101
107
|
Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
|
102
108
|
|
103
|
-
Bundler.ui.
|
109
|
+
Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, :yellow
|
104
110
|
|
105
111
|
First, try this link to see if there are any existing issue reports for this error:
|
106
112
|
#{issues_url(e)}
|
107
113
|
|
108
114
|
If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
|
109
|
-
https://github.com/
|
115
|
+
https://github.com/rubygems/rubygems/issues/new?labels=Bundler
|
110
116
|
EOS
|
111
117
|
end
|
112
118
|
|
@@ -114,16 +120,19 @@ module Bundler
|
|
114
120
|
message = exception.message.lines.first.tr(":", " ").chomp
|
115
121
|
message = message.split("-").first if exception.is_a?(Errno)
|
116
122
|
require "cgi"
|
117
|
-
"https://github.com/
|
123
|
+
"https://github.com/rubygems/rubygems/search?q=" \
|
118
124
|
"#{CGI.escape(message)}&type=Issues"
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
122
128
|
def self.with_friendly_errors
|
129
|
+
FriendlyErrors.enable!
|
123
130
|
yield
|
124
131
|
rescue SignalException
|
125
132
|
raise
|
126
133
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
134
|
+
raise if FriendlyErrors.disabled?
|
135
|
+
|
127
136
|
FriendlyErrors.log_error(e)
|
128
137
|
exit FriendlyErrors.exit_status(e)
|
129
138
|
end
|
data/lib/bundler/gem_helper.rb
CHANGED
@@ -15,6 +15,10 @@ module Bundler
|
|
15
15
|
new(opts[:dir], opts[:name]).install
|
16
16
|
end
|
17
17
|
|
18
|
+
def tag_prefix=(prefix)
|
19
|
+
instance.tag_prefix = prefix
|
20
|
+
end
|
21
|
+
|
18
22
|
def gemspec(&block)
|
19
23
|
gemspec = instance.gemspec
|
20
24
|
block.call(gemspec) if block
|
@@ -24,12 +28,15 @@ module Bundler
|
|
24
28
|
|
25
29
|
attr_reader :spec_path, :base, :gemspec
|
26
30
|
|
31
|
+
attr_writer :tag_prefix
|
32
|
+
|
27
33
|
def initialize(base = nil, name = nil)
|
28
|
-
@base = (base
|
29
|
-
gemspecs = name ? [File.join(base, "#{name}.gemspec")] :
|
34
|
+
@base = File.expand_path(base || SharedHelpers.pwd)
|
35
|
+
gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : Gem::Util.glob_files_in_dir("{,*}.gemspec", @base)
|
30
36
|
raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
|
31
37
|
@spec_path = gemspecs.first
|
32
38
|
@gemspec = Bundler.load_gemspec(@spec_path)
|
39
|
+
@tag_prefix = ""
|
33
40
|
end
|
34
41
|
|
35
42
|
def install
|
@@ -40,6 +47,11 @@ module Bundler
|
|
40
47
|
built_gem_path = build_gem
|
41
48
|
end
|
42
49
|
|
50
|
+
desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory."
|
51
|
+
task "build:checksum" => "build" do
|
52
|
+
build_checksum(built_gem_path)
|
53
|
+
end
|
54
|
+
|
43
55
|
desc "Build and install #{name}-#{version}.gem into system gems."
|
44
56
|
task "install" => "build" do
|
45
57
|
install_gem(built_gem_path)
|
@@ -73,7 +85,7 @@ module Bundler
|
|
73
85
|
|
74
86
|
def build_gem
|
75
87
|
file_name = nil
|
76
|
-
sh(
|
88
|
+
sh([*gem_command, "build", "-V", spec_path]) do
|
77
89
|
file_name = File.basename(built_gem_path)
|
78
90
|
SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
|
79
91
|
FileUtils.mv(built_gem_path, "pkg")
|
@@ -84,36 +96,57 @@ module Bundler
|
|
84
96
|
|
85
97
|
def install_gem(built_gem_path = nil, local = false)
|
86
98
|
built_gem_path ||= build_gem
|
87
|
-
cmd =
|
88
|
-
cmd
|
89
|
-
_, status = sh_with_status(cmd
|
99
|
+
cmd = [*gem_command, "install", built_gem_path.to_s]
|
100
|
+
cmd << "--local" if local
|
101
|
+
_, status = sh_with_status(cmd)
|
90
102
|
unless status.success?
|
91
103
|
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output"
|
92
104
|
end
|
93
105
|
Bundler.ui.confirm "#{name} (#{version}) installed."
|
94
106
|
end
|
95
107
|
|
96
|
-
|
108
|
+
def build_checksum(built_gem_path = nil)
|
109
|
+
built_gem_path ||= build_gem
|
110
|
+
SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
|
111
|
+
file_name = "#{File.basename(built_gem_path)}.sha512"
|
112
|
+
require "digest/sha2"
|
113
|
+
checksum = Digest::SHA512.new.hexdigest(built_gem_path.to_s)
|
114
|
+
target = File.join(base, "checksums", file_name)
|
115
|
+
File.write(target, checksum)
|
116
|
+
Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."
|
117
|
+
end
|
118
|
+
|
119
|
+
protected
|
97
120
|
|
98
121
|
def rubygem_push(path)
|
99
|
-
cmd =
|
122
|
+
cmd = [*gem_command, "push", path]
|
100
123
|
cmd << "--key" << gem_key if gem_key
|
101
124
|
cmd << "--host" << allowed_push_host if allowed_push_host
|
102
|
-
unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file?
|
103
|
-
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
|
104
|
-
end
|
105
125
|
sh_with_input(cmd)
|
106
126
|
Bundler.ui.confirm "Pushed #{name} #{version} to #{gem_push_host}"
|
107
127
|
end
|
108
128
|
|
109
129
|
def built_gem_path
|
110
|
-
|
130
|
+
Gem::Util.glob_files_in_dir("#{name}-*.gem", base).sort_by {|f| File.mtime(f) }.last
|
131
|
+
end
|
132
|
+
|
133
|
+
def git_push(remote = nil)
|
134
|
+
remote ||= default_remote
|
135
|
+
perform_git_push "#{remote} refs/heads/#{current_branch}"
|
136
|
+
perform_git_push "#{remote} refs/tags/#{version_tag}"
|
137
|
+
Bundler.ui.confirm "Pushed git commits and release tag."
|
138
|
+
end
|
139
|
+
|
140
|
+
def default_remote
|
141
|
+
remote_for_branch, status = sh_with_status(%W[git config --get branch.#{current_branch}.remote])
|
142
|
+
return "origin" unless status.success?
|
143
|
+
|
144
|
+
remote_for_branch.strip
|
111
145
|
end
|
112
146
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
Bundler.ui.confirm "Pushed git commits and tags."
|
147
|
+
def current_branch
|
148
|
+
# We can replace this with `git branch --show-current` once we drop support for git < 2.22.0
|
149
|
+
sh(%w[git rev-parse --abbrev-ref HEAD]).gsub(%r{\Aheads/}, "").strip
|
117
150
|
end
|
118
151
|
|
119
152
|
def allowed_push_host
|
@@ -168,7 +201,7 @@ module Bundler
|
|
168
201
|
end
|
169
202
|
|
170
203
|
def version_tag
|
171
|
-
"v#{version}"
|
204
|
+
"#{@tag_prefix}v#{version}"
|
172
205
|
end
|
173
206
|
|
174
207
|
def name
|
@@ -210,7 +243,7 @@ module Bundler
|
|
210
243
|
end
|
211
244
|
|
212
245
|
def gem_command
|
213
|
-
ENV["GEM_COMMAND"]
|
246
|
+
ENV["GEM_COMMAND"]&.shellsplit || ["gem"]
|
214
247
|
end
|
215
248
|
end
|
216
249
|
end
|
data/lib/bundler/gem_helpers.rb
CHANGED
@@ -24,47 +24,44 @@ module Bundler
|
|
24
24
|
module_function :generic
|
25
25
|
|
26
26
|
def generic_local_platform
|
27
|
-
generic(
|
27
|
+
generic(local_platform)
|
28
28
|
end
|
29
29
|
module_function :generic_local_platform
|
30
30
|
|
31
|
+
def local_platform
|
32
|
+
Bundler.local_platform
|
33
|
+
end
|
34
|
+
module_function :local_platform
|
35
|
+
|
31
36
|
def platform_specificity_match(spec_platform, user_platform)
|
32
37
|
spec_platform = Gem::Platform.new(spec_platform)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
PlatformMatch.new(
|
37
|
-
PlatformMatch.os_match(spec_platform, user_platform),
|
38
|
-
PlatformMatch.cpu_match(spec_platform, user_platform),
|
39
|
-
PlatformMatch.platform_version_match(spec_platform, user_platform)
|
40
|
-
)
|
38
|
+
|
39
|
+
PlatformMatch.specificity_score(spec_platform, user_platform)
|
41
40
|
end
|
42
41
|
module_function :platform_specificity_match
|
43
42
|
|
44
43
|
def select_best_platform_match(specs, platform)
|
45
|
-
specs.select {|spec| spec.match_platform(platform) }
|
46
|
-
|
44
|
+
matching = specs.select {|spec| spec.match_platform(platform) }
|
45
|
+
exact = matching.select {|spec| spec.platform == platform }
|
46
|
+
return exact if exact.any?
|
47
|
+
|
48
|
+
sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
|
49
|
+
exemplary_spec = sorted_matching.first
|
50
|
+
|
51
|
+
sorted_matching.take_while{|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
|
47
52
|
end
|
48
53
|
module_function :select_best_platform_match
|
49
54
|
|
50
|
-
PlatformMatch = Struct.new(:os_match, :cpu_match, :platform_version_match)
|
51
55
|
class PlatformMatch
|
52
|
-
def
|
53
|
-
return
|
54
|
-
|
55
|
-
m = os_match <=> other.os_match
|
56
|
-
return m unless m.zero?
|
57
|
-
|
58
|
-
m = cpu_match <=> other.cpu_match
|
59
|
-
return m unless m.zero?
|
56
|
+
def self.specificity_score(spec_platform, user_platform)
|
57
|
+
return -1 if spec_platform == user_platform
|
58
|
+
return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
|
60
59
|
|
61
|
-
|
62
|
-
|
60
|
+
os_match(spec_platform, user_platform) +
|
61
|
+
cpu_match(spec_platform, user_platform) * 10 +
|
62
|
+
platform_version_match(spec_platform, user_platform) * 100
|
63
63
|
end
|
64
64
|
|
65
|
-
EXACT_MATCH = new(-1, -1, -1).freeze
|
66
|
-
WORST_MATCH = new(1_000_000, 1_000_000, 1_000_000).freeze
|
67
|
-
|
68
65
|
def self.os_match(spec_platform, user_platform)
|
69
66
|
if spec_platform.os == user_platform.os
|
70
67
|
0
|
@@ -95,5 +92,19 @@ module Bundler
|
|
95
92
|
end
|
96
93
|
end
|
97
94
|
end
|
95
|
+
|
96
|
+
def same_specificity(platform, spec, exemplary_spec)
|
97
|
+
platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
|
98
|
+
end
|
99
|
+
module_function :same_specificity
|
100
|
+
|
101
|
+
def same_deps(spec, exemplary_spec)
|
102
|
+
same_runtime_deps = spec.dependencies.sort == exemplary_spec.dependencies.sort
|
103
|
+
return same_runtime_deps unless spec.is_a?(Gem::Specification) && exemplary_spec.is_a?(Gem::Specification)
|
104
|
+
|
105
|
+
same_metadata_deps = spec.required_ruby_version == exemplary_spec.required_ruby_version && spec.required_rubygems_version == exemplary_spec.required_rubygems_version
|
106
|
+
same_runtime_deps && same_metadata_deps
|
107
|
+
end
|
108
|
+
module_function :same_deps
|
98
109
|
end
|
99
110
|
end
|
@@ -7,7 +7,7 @@ module Bundler
|
|
7
7
|
# available dependency versions as found in its index, before returning it to
|
8
8
|
# to the resolution engine to select the best version.
|
9
9
|
class GemVersionPromoter
|
10
|
-
DEBUG = ENV["DEBUG_RESOLVER"]
|
10
|
+
DEBUG = ENV["BUNDLER_DEBUG_RESOLVER"] || ENV["DEBUG_RESOLVER"]
|
11
11
|
|
12
12
|
attr_reader :level, :locked_specs, :unlock_gems
|
13
13
|
|
@@ -81,8 +81,8 @@ module Bundler
|
|
81
81
|
sort_dep_specs(spec_groups, locked_spec)
|
82
82
|
end.tap do |specs|
|
83
83
|
if DEBUG
|
84
|
-
|
85
|
-
|
84
|
+
puts before_result
|
85
|
+
puts " after sort_versions: #{debug_format_result(dep, specs).inspect}"
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -98,7 +98,7 @@ module Bundler
|
|
98
98
|
level == :minor
|
99
99
|
end
|
100
100
|
|
101
|
-
|
101
|
+
private
|
102
102
|
|
103
103
|
def filter_dep_specs(spec_groups, locked_spec)
|
104
104
|
res = spec_groups.select do |spec_group|
|
data/lib/bundler/graph.rb
CHANGED
data/lib/bundler/index.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "set"
|
4
|
-
|
5
3
|
module Bundler
|
6
4
|
class Index
|
7
5
|
include Enumerable
|
@@ -65,11 +63,14 @@ module Bundler
|
|
65
63
|
def unsorted_search(query, base)
|
66
64
|
results = local_search(query, base)
|
67
65
|
|
68
|
-
seen = results.map(&:full_name).
|
66
|
+
seen = results.map(&:full_name).uniq unless @sources.empty?
|
69
67
|
|
70
68
|
@sources.each do |source|
|
71
69
|
source.unsorted_search(query, base).each do |spec|
|
72
|
-
|
70
|
+
next if seen.include?(spec.full_name)
|
71
|
+
|
72
|
+
seen << spec.full_name
|
73
|
+
results << spec
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -170,7 +171,7 @@ module Bundler
|
|
170
171
|
def dependencies_eql?(spec, other_spec)
|
171
172
|
deps = spec.dependencies.select {|d| d.type != :development }
|
172
173
|
other_deps = other_spec.dependencies.select {|d| d.type != :development }
|
173
|
-
|
174
|
+
deps.sort == other_deps.sort
|
174
175
|
end
|
175
176
|
|
176
177
|
def add_source(index)
|
@@ -179,7 +180,7 @@ module Bundler
|
|
179
180
|
@sources.uniq! # need to use uniq! here instead of checking for the item before adding
|
180
181
|
end
|
181
182
|
|
182
|
-
|
183
|
+
private
|
183
184
|
|
184
185
|
def specs_by_name(name)
|
185
186
|
@specs[name].values
|
@@ -195,7 +196,11 @@ module Bundler
|
|
195
196
|
if base # allow all platforms when searching from a lockfile
|
196
197
|
dependency.matches_spec?(spec)
|
197
198
|
else
|
198
|
-
|
199
|
+
if Gem::Platform.respond_to? :match_spec?
|
200
|
+
dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
|
201
|
+
else
|
202
|
+
dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
|
203
|
+
end
|
199
204
|
end
|
200
205
|
end
|
201
206
|
|
data/lib/bundler/injector.rb
CHANGED
@@ -74,7 +74,7 @@ module Bundler
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
private
|
78
78
|
|
79
79
|
def conservative_version(spec)
|
80
80
|
version = spec.version
|
@@ -128,7 +128,7 @@ module Bundler
|
|
128
128
|
# evaluates a gemfile to remove the specified gem
|
129
129
|
# from it.
|
130
130
|
def remove_deps(gemfile_path)
|
131
|
-
initial_gemfile =
|
131
|
+
initial_gemfile = File.readlines(gemfile_path)
|
132
132
|
|
133
133
|
Bundler.ui.info "Removing gems from #{gemfile_path}"
|
134
134
|
|
@@ -179,11 +179,22 @@ module Bundler
|
|
179
179
|
# @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
|
180
180
|
def remove_gems_from_gemfile(gems, gemfile_path)
|
181
181
|
patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
|
182
|
+
new_gemfile = []
|
183
|
+
multiline_removal = false
|
184
|
+
File.readlines(gemfile_path).each do |line|
|
185
|
+
match_data = line.match(patterns)
|
186
|
+
if match_data && is_not_within_comment?(line, match_data)
|
187
|
+
multiline_removal = line.rstrip.end_with?(",")
|
188
|
+
# skip lines which match the regex
|
189
|
+
next
|
190
|
+
end
|
182
191
|
|
183
|
-
|
184
|
-
|
192
|
+
# skip followup lines until line does not end with ','
|
193
|
+
new_gemfile << line unless multiline_removal
|
194
|
+
multiline_removal = line.rstrip.end_with?(",") if multiline_removal
|
195
|
+
end
|
185
196
|
|
186
|
-
# remove
|
197
|
+
# remove line \n and append them with other strings
|
187
198
|
new_gemfile.each_with_index do |_line, index|
|
188
199
|
if new_gemfile[index + 1] == "\n"
|
189
200
|
new_gemfile[index] += new_gemfile[index + 1]
|
@@ -196,6 +207,13 @@ module Bundler
|
|
196
207
|
new_gemfile.join.chomp
|
197
208
|
end
|
198
209
|
|
210
|
+
# @param [String] line Individual line of gemfile content.
|
211
|
+
# @param [MatchData] match_data Data about Regex match.
|
212
|
+
def is_not_within_comment?(line, match_data)
|
213
|
+
match_start_index = match_data.offset(0).first
|
214
|
+
!line[0..match_start_index].include?("#")
|
215
|
+
end
|
216
|
+
|
199
217
|
# @param [Array] gemfile Array of gemfile contents.
|
200
218
|
# @param [String] block_name Name of block name to look for.
|
201
219
|
def remove_nested_blocks(gemfile, block_name)
|