shopify-bundler 1.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +96 -0
- data/.rubocop_todo.yml +177 -0
- data/.travis.yml +104 -0
- data/CHANGELOG.md +2131 -0
- data/CODE_OF_CONDUCT.md +42 -0
- data/CONTRIBUTING.md +32 -0
- data/DEVELOPMENT.md +118 -0
- data/ISSUES.md +96 -0
- data/LICENSE.md +23 -0
- data/README.md +40 -0
- data/Rakefile +309 -0
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +34 -0
- data/exe/bundle +21 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +21 -0
- data/lib/bundler.rb +499 -0
- data/lib/bundler/capistrano.rb +16 -0
- data/lib/bundler/cli.rb +435 -0
- data/lib/bundler/cli/binstubs.rb +37 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +37 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +56 -0
- data/lib/bundler/cli/config.rb +88 -0
- data/lib/bundler/cli/console.rb +37 -0
- data/lib/bundler/cli/exec.rb +51 -0
- data/lib/bundler/cli/gem.rb +208 -0
- data/lib/bundler/cli/init.rb +32 -0
- data/lib/bundler/cli/inject.rb +32 -0
- data/lib/bundler/cli/install.rb +188 -0
- data/lib/bundler/cli/lock.rb +35 -0
- data/lib/bundler/cli/open.rb +22 -0
- data/lib/bundler/cli/outdated.rb +86 -0
- data/lib/bundler/cli/package.rb +45 -0
- data/lib/bundler/cli/platform.rb +42 -0
- data/lib/bundler/cli/show.rb +74 -0
- data/lib/bundler/cli/update.rb +72 -0
- data/lib/bundler/cli/viz.rb +26 -0
- data/lib/bundler/constants.rb +5 -0
- data/lib/bundler/current_ruby.rb +218 -0
- data/lib/bundler/definition.rb +675 -0
- data/lib/bundler/dep_proxy.rb +45 -0
- data/lib/bundler/dependency.rb +119 -0
- data/lib/bundler/deployment.rb +62 -0
- data/lib/bundler/deprecate.rb +17 -0
- data/lib/bundler/dsl.rb +478 -0
- data/lib/bundler/endpoint_specification.rb +100 -0
- data/lib/bundler/env.rb +82 -0
- data/lib/bundler/environment.rb +41 -0
- data/lib/bundler/fetcher.rb +288 -0
- data/lib/bundler/fetcher/base.rb +26 -0
- data/lib/bundler/fetcher/dependency.rb +88 -0
- data/lib/bundler/fetcher/downloader.rb +60 -0
- data/lib/bundler/fetcher/index.rb +32 -0
- data/lib/bundler/friendly_errors.rb +92 -0
- data/lib/bundler/gem_helper.rb +191 -0
- data/lib/bundler/gem_helpers.rb +26 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_path_manipulation.rb +8 -0
- data/lib/bundler/gem_tasks.rb +5 -0
- data/lib/bundler/graph.rb +173 -0
- data/lib/bundler/index.rb +199 -0
- data/lib/bundler/injector.rb +62 -0
- data/lib/bundler/inline.rb +58 -0
- data/lib/bundler/installer.rb +242 -0
- data/lib/bundler/installer/parallel_installer.rb +122 -0
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/lazy_specification.rb +82 -0
- data/lib/bundler/lockfile_parser.rb +199 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +26 -0
- data/lib/bundler/remote_specification.rb +82 -0
- data/lib/bundler/resolver.rb +350 -0
- data/lib/bundler/retry.rb +60 -0
- data/lib/bundler/ruby_dsl.rb +11 -0
- data/lib/bundler/ruby_version.rb +116 -0
- data/lib/bundler/rubygems_ext.rb +175 -0
- data/lib/bundler/rubygems_integration.rb +674 -0
- data/lib/bundler/runtime.rb +285 -0
- data/lib/bundler/settings.rb +263 -0
- data/lib/bundler/setup.rb +26 -0
- data/lib/bundler/shared_helpers.rb +176 -0
- data/lib/bundler/similarity_detector.rb +61 -0
- data/lib/bundler/source.rb +35 -0
- data/lib/bundler/source/git.rb +286 -0
- data/lib/bundler/source/git/git_proxy.rb +190 -0
- data/lib/bundler/source/path.rb +224 -0
- data/lib/bundler/source/path/installer.rb +43 -0
- data/lib/bundler/source/rubygems.rb +436 -0
- data/lib/bundler/source/rubygems/remote.rb +38 -0
- data/lib/bundler/source_list.rb +101 -0
- data/lib/bundler/spec_set.rb +156 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +25 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +32 -0
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +64 -0
- data/lib/bundler/stub_specification.rb +23 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/.travis.yml.tt +4 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +22 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +41 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +16 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +43 -0
- data/lib/bundler/templates/newgem/rspec.tt +2 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
- data/lib/bundler/ui.rb +7 -0
- data/lib/bundler/ui/rg_proxy.rb +17 -0
- data/lib/bundler/ui/shell.rb +108 -0
- data/lib/bundler/ui/silent.rb +44 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +277 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +3 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +99 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +434 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +43 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +51 -0
- data/lib/bundler/vendor/net/http/faster.rb +26 -0
- data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +484 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +73 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +267 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_molinillo.rb +2 -0
- data/lib/bundler/vendored_persistent.rb +11 -0
- data/lib/bundler/vendored_thor.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/lib/bundler/worker.rb +72 -0
- data/man/bundle-config.ronn +187 -0
- data/man/bundle-exec.ronn +136 -0
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +398 -0
- data/man/bundle-package.ronn +66 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-update.ronn +188 -0
- data/man/bundle.ronn +98 -0
- data/man/gemfile.5.ronn +495 -0
- data/man/index.txt +8 -0
- metadata +346 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require "bundler/shared_helpers"
|
2
|
+
|
3
|
+
if Bundler::SharedHelpers.in_bundle?
|
4
|
+
require "bundler"
|
5
|
+
|
6
|
+
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
|
7
|
+
begin
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
puts "\e[31m#{e.message}\e[0m"
|
11
|
+
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
12
|
+
if e.is_a?(Bundler::GemNotFound)
|
13
|
+
puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
|
14
|
+
end
|
15
|
+
exit e.status_code
|
16
|
+
end
|
17
|
+
else
|
18
|
+
Bundler.setup
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add bundler to the load path after disabling system gems
|
22
|
+
bundler_lib = File.expand_path("../..", __FILE__)
|
23
|
+
$LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
|
24
|
+
|
25
|
+
Bundler.ui = nil
|
26
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
require "bundler/constants"
|
5
|
+
require "bundler/rubygems_integration"
|
6
|
+
require "bundler/current_ruby"
|
7
|
+
|
8
|
+
module Gem
|
9
|
+
class Dependency
|
10
|
+
unless method_defined? :requirement
|
11
|
+
def requirement
|
12
|
+
version_requirements
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Bundler
|
19
|
+
module SharedHelpers
|
20
|
+
attr_accessor :gem_loaded
|
21
|
+
|
22
|
+
def default_gemfile
|
23
|
+
gemfile = find_gemfile
|
24
|
+
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
25
|
+
Pathname.new(gemfile)
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_lockfile
|
29
|
+
gemfile = default_gemfile
|
30
|
+
|
31
|
+
case gemfile.basename.to_s
|
32
|
+
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
|
33
|
+
else Pathname.new("#{gemfile}.lock")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_bundle_dir
|
38
|
+
bundle_dir = find_directory(".bundle")
|
39
|
+
return nil unless bundle_dir
|
40
|
+
|
41
|
+
global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle")
|
42
|
+
return nil if bundle_dir == global_bundle_dir
|
43
|
+
|
44
|
+
Pathname.new(bundle_dir)
|
45
|
+
end
|
46
|
+
|
47
|
+
def in_bundle?
|
48
|
+
find_gemfile
|
49
|
+
end
|
50
|
+
|
51
|
+
def chdir(dir, &blk)
|
52
|
+
Bundler.rubygems.ext_lock.synchronize do
|
53
|
+
Dir.chdir dir, &blk
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def pwd
|
58
|
+
Bundler.rubygems.ext_lock.synchronize do
|
59
|
+
Pathname.pwd
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def with_clean_git_env(&block)
|
64
|
+
keys = %w[GIT_DIR GIT_WORK_TREE]
|
65
|
+
old_env = keys.inject({}) do |h, k|
|
66
|
+
h.update(k => ENV[k])
|
67
|
+
end
|
68
|
+
|
69
|
+
keys.each {|key| ENV.delete(key) }
|
70
|
+
|
71
|
+
block.call
|
72
|
+
ensure
|
73
|
+
keys.each {|key| ENV[key] = old_env[key] }
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_bundle_environment
|
77
|
+
# Set PATH
|
78
|
+
paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
|
79
|
+
paths.unshift "#{Bundler.bundle_path}/bin"
|
80
|
+
ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
|
81
|
+
|
82
|
+
# Set RUBYOPT
|
83
|
+
rubyopt = [ENV["RUBYOPT"]].compact
|
84
|
+
if rubyopt.empty? || rubyopt.first !~ %r{-rbundler/setup}
|
85
|
+
rubyopt.unshift %|-rbundler/setup|
|
86
|
+
ENV["RUBYOPT"] = rubyopt.join(" ")
|
87
|
+
end
|
88
|
+
|
89
|
+
# Set RUBYLIB
|
90
|
+
rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
|
91
|
+
rubylib.unshift File.expand_path("../..", __FILE__)
|
92
|
+
ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Rescues permissions errors raised by file system operations
|
96
|
+
# (ie. Errno:EACCESS) and raises more friendly errors instead.
|
97
|
+
#
|
98
|
+
# @param path [String] the path that the action will be attempted to
|
99
|
+
# @param action [Symbol, #to_s] the type of operation that will be
|
100
|
+
# performed. For example: :write, :read, :exec
|
101
|
+
#
|
102
|
+
# @yield path
|
103
|
+
#
|
104
|
+
# @raise [Bundler::PermissionError] if Errno:EACCES is raised in the
|
105
|
+
# given block
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# filesystem_access("vendor/cache", :write) do
|
109
|
+
# FileUtils.mkdir_p("vendor/cache")
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# @see {Bundler::PermissionError}
|
113
|
+
def filesystem_access(path, action = :write)
|
114
|
+
yield path
|
115
|
+
rescue Errno::EACCES
|
116
|
+
raise PermissionError.new(path, action)
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def find_gemfile
|
122
|
+
given = ENV["BUNDLE_GEMFILE"]
|
123
|
+
return given if given && !given.empty?
|
124
|
+
|
125
|
+
find_file("Gemfile", "gems.rb")
|
126
|
+
end
|
127
|
+
|
128
|
+
def find_file(*names)
|
129
|
+
search_up(*names) {|filename|
|
130
|
+
return filename if File.file?(filename)
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def find_directory(*names)
|
135
|
+
search_up(*names) do |dirname|
|
136
|
+
return dirname if File.directory?(dirname)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def search_up(*names)
|
141
|
+
previous = nil
|
142
|
+
current = File.expand_path(SharedHelpers.pwd)
|
143
|
+
|
144
|
+
until !File.directory?(current) || current == previous
|
145
|
+
if ENV["BUNDLE_SPEC_RUN"]
|
146
|
+
# avoid stepping above the tmp directory when testing
|
147
|
+
return nil if File.file?(File.join(current, "bundler.gemspec"))
|
148
|
+
end
|
149
|
+
|
150
|
+
names.each do |name|
|
151
|
+
filename = File.join(current, name)
|
152
|
+
yield filename
|
153
|
+
end
|
154
|
+
current, previous = File.expand_path("..", current), current
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def clean_load_path
|
159
|
+
# handle 1.9 where system gems are always on the load path
|
160
|
+
if defined?(::Gem)
|
161
|
+
me = File.expand_path("../../", __FILE__)
|
162
|
+
me = /^#{Regexp.escape(me)}/
|
163
|
+
|
164
|
+
loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
|
165
|
+
|
166
|
+
$LOAD_PATH.reject! do |p|
|
167
|
+
next if File.expand_path(p) =~ me
|
168
|
+
loaded_gem_paths.delete(p)
|
169
|
+
end
|
170
|
+
$LOAD_PATH.uniq!
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
extend self
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Bundler
|
2
|
+
class SimilarityDetector
|
3
|
+
SimilarityScore = Struct.new(:string, :distance)
|
4
|
+
|
5
|
+
# initialize with an array of words to be matched against
|
6
|
+
def initialize(corpus)
|
7
|
+
@corpus = corpus
|
8
|
+
end
|
9
|
+
|
10
|
+
# return an array of words similar to 'word' from the corpus
|
11
|
+
def similar_words(word, limit = 3)
|
12
|
+
words_by_similarity = @corpus.map {|w| SimilarityScore.new(w, levenshtein_distance(word, w)) }
|
13
|
+
words_by_similarity.select {|s| s.distance <= limit }.sort_by(&:distance).map(&:string)
|
14
|
+
end
|
15
|
+
|
16
|
+
# return the result of 'similar_words', concatenated into a list
|
17
|
+
# (eg "a, b, or c")
|
18
|
+
def similar_word_list(word, limit = 3)
|
19
|
+
words = similar_words(word, limit)
|
20
|
+
if words.length == 1
|
21
|
+
words[0]
|
22
|
+
elsif words.length > 1
|
23
|
+
[words[0..-2].join(", "), words[-1]].join(" or ")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
# http://www.informit.com/articles/article.aspx?p=683059&seqNum=36
|
30
|
+
def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
|
31
|
+
# ins, del, sub are weighted costs
|
32
|
+
return nil if this.nil?
|
33
|
+
return nil if that.nil?
|
34
|
+
dm = [] # distance matrix
|
35
|
+
|
36
|
+
# Initialize first row values
|
37
|
+
dm[0] = (0..this.length).collect {|i| i * ins }
|
38
|
+
fill = [0] * (this.length - 1)
|
39
|
+
|
40
|
+
# Initialize first column values
|
41
|
+
(1..that.length).each do |i|
|
42
|
+
dm[i] = [i * del, fill.flatten]
|
43
|
+
end
|
44
|
+
|
45
|
+
# populate matrix
|
46
|
+
(1..that.length).each do |i|
|
47
|
+
(1..this.length).each do |j|
|
48
|
+
# critical comparison
|
49
|
+
dm[i][j] = [
|
50
|
+
dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub),
|
51
|
+
dm[i][j - 1] + ins,
|
52
|
+
dm[i - 1][j] + del
|
53
|
+
].min
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# The last value in matrix is the Levenshtein distance between the strings
|
58
|
+
dm[that.length][this.length]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Source
|
3
|
+
autoload :Rubygems, "bundler/source/rubygems"
|
4
|
+
autoload :Path, "bundler/source/path"
|
5
|
+
autoload :Git, "bundler/source/git"
|
6
|
+
|
7
|
+
attr_accessor :dependency_names
|
8
|
+
|
9
|
+
def unmet_deps
|
10
|
+
specs.unmet_dependency_names
|
11
|
+
end
|
12
|
+
|
13
|
+
def version_message(spec)
|
14
|
+
message = "#{spec.name} #{spec.version}"
|
15
|
+
|
16
|
+
if Bundler.locked_gems
|
17
|
+
locked_spec = Bundler.locked_gems.specs.find {|s| s.name == spec.name }
|
18
|
+
locked_spec_version = locked_spec.version if locked_spec
|
19
|
+
if locked_spec_version && spec.version != locked_spec_version
|
20
|
+
message << " (was #{locked_spec_version})"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
message
|
25
|
+
end
|
26
|
+
|
27
|
+
def can_lock?(spec)
|
28
|
+
spec.source == self
|
29
|
+
end
|
30
|
+
|
31
|
+
def include?(other)
|
32
|
+
other == self
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "uri"
|
3
|
+
require "digest/sha1"
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
class Source
|
7
|
+
class Git < Path
|
8
|
+
autoload :GitProxy, "bundler/source/git/git_proxy"
|
9
|
+
|
10
|
+
attr_reader :uri, :ref, :branch, :options, :submodules
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@options = options
|
14
|
+
@glob = options["glob"] || DEFAULT_GLOB
|
15
|
+
|
16
|
+
@allow_cached = false
|
17
|
+
@allow_remote = false
|
18
|
+
|
19
|
+
# Stringify options that could be set as symbols
|
20
|
+
%w(ref branch tag revision).each {|k| options[k] = options[k].to_s if options[k] }
|
21
|
+
|
22
|
+
@uri = options["uri"] || ""
|
23
|
+
@branch = options["branch"]
|
24
|
+
@ref = options["ref"] || options["branch"] || options["tag"] || "master"
|
25
|
+
@submodules = options["submodules"]
|
26
|
+
@name = options["name"]
|
27
|
+
@version = options["version"]
|
28
|
+
|
29
|
+
@copied = false
|
30
|
+
@local = false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.from_lock(options)
|
34
|
+
new(options.merge("uri" => options.delete("remote")))
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_lock
|
38
|
+
out = "GIT\n"
|
39
|
+
out << " remote: #{@uri}\n"
|
40
|
+
out << " revision: #{revision}\n"
|
41
|
+
%w(ref branch tag submodules).each do |opt|
|
42
|
+
out << " #{opt}: #{options[opt]}\n" if options[opt]
|
43
|
+
end
|
44
|
+
out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
|
45
|
+
out << " specs:\n"
|
46
|
+
end
|
47
|
+
|
48
|
+
def hash
|
49
|
+
[self.class, uri, ref, branch, name, version, submodules].hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def eql?(other)
|
53
|
+
other.is_a?(Git) && uri == other.uri && ref == other.ref &&
|
54
|
+
branch == other.branch && name == other.name &&
|
55
|
+
version == other.version && submodules == other.submodules
|
56
|
+
end
|
57
|
+
|
58
|
+
alias_method :==, :eql?
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
at = if local?
|
62
|
+
path
|
63
|
+
elsif options["ref"]
|
64
|
+
shortref_for_display(options["ref"])
|
65
|
+
else
|
66
|
+
ref
|
67
|
+
end
|
68
|
+
"#{uri} (at #{at})"
|
69
|
+
end
|
70
|
+
|
71
|
+
def name
|
72
|
+
File.basename(@uri, ".git")
|
73
|
+
end
|
74
|
+
|
75
|
+
# This is the path which is going to contain a specific
|
76
|
+
# checkout of the git repository. When using local git
|
77
|
+
# repos, this is set to the local repo.
|
78
|
+
def install_path
|
79
|
+
@install_path ||= begin
|
80
|
+
git_scope = "#{base_name}-#{shortref_for_path(revision)}"
|
81
|
+
path = Bundler.install_path.join(git_scope)
|
82
|
+
|
83
|
+
if !path.exist? && Bundler.requires_sudo?
|
84
|
+
Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
|
85
|
+
else
|
86
|
+
path
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
alias_method :path, :install_path
|
92
|
+
|
93
|
+
def extension_dir_name
|
94
|
+
"#{base_name}-#{shortref_for_path(revision)}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def unlock!
|
98
|
+
git_proxy.revision = nil
|
99
|
+
@unlocked = true
|
100
|
+
end
|
101
|
+
|
102
|
+
def local_override!(path)
|
103
|
+
return false if local?
|
104
|
+
|
105
|
+
path = Pathname.new(path)
|
106
|
+
path = path.expand_path(Bundler.root) unless path.relative?
|
107
|
+
|
108
|
+
unless options["branch"] || Bundler.settings[:disable_local_branch_check]
|
109
|
+
raise GitError, "Cannot use local override for #{name} at #{path} because " \
|
110
|
+
":branch is not specified in Gemfile. Specify a branch or use " \
|
111
|
+
"`bundle config --delete` to remove the local override"
|
112
|
+
end
|
113
|
+
|
114
|
+
unless path.exist?
|
115
|
+
raise GitError, "Cannot use local override for #{name} because #{path} " \
|
116
|
+
"does not exist. Check `bundle config --delete` to remove the local override"
|
117
|
+
end
|
118
|
+
|
119
|
+
set_local!(path)
|
120
|
+
|
121
|
+
# Create a new git proxy without the cached revision
|
122
|
+
# so the Gemfile.lock always picks up the new revision.
|
123
|
+
@git_proxy = GitProxy.new(path, uri, ref)
|
124
|
+
|
125
|
+
if git_proxy.branch != options["branch"] && !Bundler.settings[:disable_local_branch_check]
|
126
|
+
raise GitError, "Local override for #{name} at #{path} is using branch " \
|
127
|
+
"#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
|
128
|
+
end
|
129
|
+
|
130
|
+
changed = cached_revision && cached_revision != git_proxy.revision
|
131
|
+
|
132
|
+
if changed && !@unlocked && !git_proxy.contains?(cached_revision)
|
133
|
+
raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
|
134
|
+
"but the current branch in your local override for #{name} does not contain such commit. " \
|
135
|
+
"Please make sure your branch is up to date."
|
136
|
+
end
|
137
|
+
|
138
|
+
changed
|
139
|
+
end
|
140
|
+
|
141
|
+
# TODO: actually cache git specs
|
142
|
+
def specs(*)
|
143
|
+
if has_app_cache? && !local?
|
144
|
+
set_local!(app_cache_path)
|
145
|
+
end
|
146
|
+
|
147
|
+
if requires_checkout? && !@copied
|
148
|
+
git_proxy.checkout
|
149
|
+
git_proxy.copy_to(install_path, submodules)
|
150
|
+
serialize_gemspecs_in(install_path)
|
151
|
+
@copied = true
|
152
|
+
end
|
153
|
+
|
154
|
+
local_specs
|
155
|
+
end
|
156
|
+
|
157
|
+
def install(spec, force = false)
|
158
|
+
Bundler.ui.info "Using #{version_message(spec)} from #{self}"
|
159
|
+
|
160
|
+
if requires_checkout? && !@copied && !force
|
161
|
+
Bundler.ui.debug " * Checking out revision: #{ref}"
|
162
|
+
git_proxy.copy_to(install_path, submodules)
|
163
|
+
serialize_gemspecs_in(install_path)
|
164
|
+
@copied = true
|
165
|
+
end
|
166
|
+
generate_bin(spec)
|
167
|
+
|
168
|
+
requires_checkout? ? spec.post_install_message : nil
|
169
|
+
end
|
170
|
+
|
171
|
+
def cache(spec, custom_path = nil)
|
172
|
+
app_cache_path = app_cache_path(custom_path)
|
173
|
+
return unless Bundler.settings[:cache_all]
|
174
|
+
return if path == app_cache_path
|
175
|
+
cached!
|
176
|
+
FileUtils.rm_rf(app_cache_path)
|
177
|
+
git_proxy.checkout if requires_checkout?
|
178
|
+
git_proxy.copy_to(app_cache_path, @submodules)
|
179
|
+
serialize_gemspecs_in(app_cache_path)
|
180
|
+
end
|
181
|
+
|
182
|
+
def load_spec_files
|
183
|
+
super
|
184
|
+
rescue PathError => e
|
185
|
+
Bundler.ui.trace e
|
186
|
+
raise GitError, "#{self} is not yet checked out. Run `bundle install` first."
|
187
|
+
end
|
188
|
+
|
189
|
+
# This is the path which is going to contain a cache
|
190
|
+
# of the git repository. When using the same git repository
|
191
|
+
# across different projects, this cache will be shared.
|
192
|
+
# When using local git repos, this is set to the local repo.
|
193
|
+
def cache_path
|
194
|
+
@cache_path ||= begin
|
195
|
+
git_scope = "#{base_name}-#{uri_hash}"
|
196
|
+
|
197
|
+
if Bundler.requires_sudo?
|
198
|
+
Bundler.user_bundle_path.join("cache/git", git_scope)
|
199
|
+
else
|
200
|
+
Bundler.cache.join("git", git_scope)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def app_cache_dirname
|
206
|
+
"#{base_name}-#{shortref_for_path(cached_revision || revision)}"
|
207
|
+
end
|
208
|
+
|
209
|
+
def revision
|
210
|
+
git_proxy.revision
|
211
|
+
end
|
212
|
+
|
213
|
+
def allow_git_ops?
|
214
|
+
@allow_remote || @allow_cached
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
|
219
|
+
def serialize_gemspecs_in(destination)
|
220
|
+
expanded_path = destination.expand_path(Bundler.root)
|
221
|
+
Dir["#{expanded_path}/#{@glob}"].each do |spec_path|
|
222
|
+
# Evaluate gemspecs and cache the result. Gemspecs
|
223
|
+
# in git might require git or other dependencies.
|
224
|
+
# The gemspecs we cache should already be evaluated.
|
225
|
+
spec = Bundler.load_gemspec(spec_path)
|
226
|
+
next unless spec
|
227
|
+
File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def set_local!(path)
|
232
|
+
@local = true
|
233
|
+
@local_specs = @git_proxy = nil
|
234
|
+
@cache_path = @install_path = path
|
235
|
+
end
|
236
|
+
|
237
|
+
def has_app_cache?
|
238
|
+
cached_revision && super
|
239
|
+
end
|
240
|
+
|
241
|
+
def local?
|
242
|
+
@local
|
243
|
+
end
|
244
|
+
|
245
|
+
def requires_checkout?
|
246
|
+
allow_git_ops? && !local?
|
247
|
+
end
|
248
|
+
|
249
|
+
def base_name
|
250
|
+
File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)?(//\w*/)?(\w*/)*}, ""), ".git")
|
251
|
+
end
|
252
|
+
|
253
|
+
def shortref_for_display(ref)
|
254
|
+
ref[0..6]
|
255
|
+
end
|
256
|
+
|
257
|
+
def shortref_for_path(ref)
|
258
|
+
ref[0..11]
|
259
|
+
end
|
260
|
+
|
261
|
+
def uri_hash
|
262
|
+
if uri =~ %r{^\w+://(\w+@)?}
|
263
|
+
# Downcase the domain component of the URI
|
264
|
+
# and strip off a trailing slash, if one is present
|
265
|
+
input = URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
|
266
|
+
else
|
267
|
+
# If there is no URI scheme, assume it is an ssh/git URI
|
268
|
+
input = uri
|
269
|
+
end
|
270
|
+
Digest::SHA1.hexdigest(input)
|
271
|
+
end
|
272
|
+
|
273
|
+
def cached_revision
|
274
|
+
options["revision"]
|
275
|
+
end
|
276
|
+
|
277
|
+
def cached?
|
278
|
+
cache_path.exist?
|
279
|
+
end
|
280
|
+
|
281
|
+
def git_proxy
|
282
|
+
@git_proxy ||= GitProxy.new(cache_path, uri, ref, cached_revision, self)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|