librarian-puppet 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.md +0 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +7 -0
- data/lib/librarian/puppet/cli.rb +30 -0
- data/lib/librarian/puppet/dsl.rb +14 -0
- data/lib/librarian/puppet/environment.rb +18 -0
- data/lib/librarian/puppet/extension.rb +9 -0
- data/lib/librarian/puppet/source.rb +2 -0
- data/lib/librarian/puppet/source/git.rb +12 -0
- data/lib/librarian/puppet/source/local.rb +46 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +6 -0
- data/librarian-puppet.gemspec +126 -0
- data/vendor/librarian/.rspec +1 -0
- data/vendor/librarian/.travis.yml +6 -0
- data/vendor/librarian/CHANGELOG.md +168 -0
- data/vendor/librarian/Gemfile +4 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +318 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +10 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +65 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +19 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +22 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +95 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
- data/vendor/librarian/lib/librarian/action/update.rb +78 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +19 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +47 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +63 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +434 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +175 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/vendor/librarian/lib/librarian/dependency.rb +95 -0
- data/vendor/librarian/lib/librarian/dsl.rb +105 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +176 -0
- data/vendor/librarian/lib/librarian/environment.rb +129 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/helpers/debug.rb +35 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +33 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +70 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +104 -0
- data/vendor/librarian/lib/librarian/manifest.rb +140 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +44 -0
- data/vendor/librarian/lib/librarian/resolver.rb +73 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +122 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/git.rb +150 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +213 -0
- data/vendor/librarian/lib/librarian/source/local.rb +51 -0
- data/vendor/librarian/lib/librarian/source/path.rb +74 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +170 -0
- data/vendor/librarian/lib/librarian/specfile.rb +22 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +33 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +30 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +30 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +163 -0
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
require 'librarian/helpers/debug'
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
module Source
|
7
|
+
class Git
|
8
|
+
class Repository
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def clone!(environment, path, repository_url)
|
12
|
+
path = Pathname.new(path)
|
13
|
+
path.mkpath
|
14
|
+
git = new(environment, path)
|
15
|
+
git.clone!(repository_url)
|
16
|
+
git
|
17
|
+
end
|
18
|
+
|
19
|
+
def bin
|
20
|
+
@bin ||= which("git") or raise Error, "cannot find git"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Cross-platform way of finding an executable in the $PATH.
|
26
|
+
#
|
27
|
+
# which('ruby') #=> /usr/bin/ruby
|
28
|
+
#
|
29
|
+
# From:
|
30
|
+
# https://github.com/defunkt/hub/commit/353031307e704d860826fc756ff0070be5e1b430#L2R173
|
31
|
+
def which(cmd)
|
32
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
33
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
34
|
+
path = File.expand_path(path)
|
35
|
+
exts.each do |ext|
|
36
|
+
exe = File.join(path, cmd + ext)
|
37
|
+
return exe if File.executable?(exe)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include Helpers::Debug
|
45
|
+
|
46
|
+
attr_accessor :environment, :path
|
47
|
+
private :environment=, :path=
|
48
|
+
|
49
|
+
def initialize(environment, path)
|
50
|
+
self.environment = environment
|
51
|
+
self.path = Pathname.new(path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def git?
|
55
|
+
path.join('.git').exist?
|
56
|
+
end
|
57
|
+
|
58
|
+
def default_remote
|
59
|
+
"origin"
|
60
|
+
end
|
61
|
+
|
62
|
+
def version(options = { })
|
63
|
+
version!(options).strip
|
64
|
+
end
|
65
|
+
|
66
|
+
def version!(options = { })
|
67
|
+
silent = options.delete(:silent)
|
68
|
+
|
69
|
+
command = %w(--version)
|
70
|
+
run!(command, :silent => silent)
|
71
|
+
end
|
72
|
+
|
73
|
+
def clone!(repository_url)
|
74
|
+
command = %W(clone #{repository_url} . --quiet)
|
75
|
+
run!(command, :chdir => true)
|
76
|
+
end
|
77
|
+
|
78
|
+
def checkout!(reference, options ={ })
|
79
|
+
command = %W(checkout #{reference} --quiet)
|
80
|
+
command << "--force" if options[:force]
|
81
|
+
run!(command, :chdir => true)
|
82
|
+
end
|
83
|
+
|
84
|
+
def fetch!(remote, options = { })
|
85
|
+
command = %W(fetch #{remote} --quiet)
|
86
|
+
command << "--tags" if options[:tags]
|
87
|
+
run!(command, :chdir => true)
|
88
|
+
end
|
89
|
+
|
90
|
+
def reset_hard!
|
91
|
+
command = %W(reset --hard --quiet)
|
92
|
+
run!(command, :chdir => true)
|
93
|
+
end
|
94
|
+
|
95
|
+
def clean!
|
96
|
+
command = %w(clean -x -d --force --force)
|
97
|
+
run!(command, :chdir => true)
|
98
|
+
end
|
99
|
+
|
100
|
+
def checked_out?(sha)
|
101
|
+
current_commit_hash == sha
|
102
|
+
end
|
103
|
+
|
104
|
+
def remote_names
|
105
|
+
command = %W(remote)
|
106
|
+
run!(command, :chdir => true).strip.lines.map(&:strip)
|
107
|
+
end
|
108
|
+
|
109
|
+
def remote_branch_names
|
110
|
+
remotes = remote_names.sort_by(&:length).reverse
|
111
|
+
|
112
|
+
command = %W(branch -r)
|
113
|
+
names = run!(command, :chdir => true).strip.lines.map(&:strip).to_a
|
114
|
+
names.each{|n| n.gsub!(/\s*->.*$/, "")}
|
115
|
+
names.reject!{|n| n =~ /\/HEAD$/}
|
116
|
+
Hash[remotes.map do |r|
|
117
|
+
matching_names = names.select{|n| n.start_with?("#{r}/")}
|
118
|
+
matching_names.each{|n| names.delete(n)}
|
119
|
+
matching_names.each{|n| n.slice!(0, r.size + 1)}
|
120
|
+
[r, matching_names]
|
121
|
+
end]
|
122
|
+
end
|
123
|
+
|
124
|
+
def hash_from(remote, reference)
|
125
|
+
branch_names = remote_branch_names[remote]
|
126
|
+
if branch_names.include?(reference)
|
127
|
+
reference = "#{remote}/#{reference}"
|
128
|
+
end
|
129
|
+
|
130
|
+
command = %W(rev-parse #{reference} --quiet)
|
131
|
+
run!(command, :chdir => true).strip
|
132
|
+
end
|
133
|
+
|
134
|
+
def current_commit_hash
|
135
|
+
command = %W(rev-parse HEAD --quiet)
|
136
|
+
run!(command, :chdir => true).strip!
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def bin
|
142
|
+
self.class.bin
|
143
|
+
end
|
144
|
+
|
145
|
+
def run!(args, options = { })
|
146
|
+
chdir = options.delete(:chdir)
|
147
|
+
chdir = path.to_s if chdir == true
|
148
|
+
|
149
|
+
silent = options.delete(:silent)
|
150
|
+
|
151
|
+
command = [bin]
|
152
|
+
command.concat(args)
|
153
|
+
|
154
|
+
maybe_within(chdir) do
|
155
|
+
logging_command(command, :silent => silent) do
|
156
|
+
run_command_internal(command)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def maybe_within(path)
|
162
|
+
if path
|
163
|
+
Dir.chdir(path) { with_env_var("GIT_DIR", nil) { yield } }
|
164
|
+
else
|
165
|
+
yield
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def with_env_var(name, value)
|
170
|
+
original_value = ENV[name]
|
171
|
+
begin
|
172
|
+
ENV[name] = value
|
173
|
+
yield
|
174
|
+
ensure
|
175
|
+
ENV[name] = original_value
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def logging_command(command, options)
|
180
|
+
silent = options.delete(:silent)
|
181
|
+
|
182
|
+
pwd = Dir.pwd
|
183
|
+
|
184
|
+
unless silent
|
185
|
+
debug { "Running `#{command.join(' ')}` in #{relative_path_to(pwd)}" }
|
186
|
+
end
|
187
|
+
|
188
|
+
out = yield
|
189
|
+
|
190
|
+
unless silent
|
191
|
+
if out.size > 0
|
192
|
+
out.lines.each do |line|
|
193
|
+
debug { " --> #{line}" }
|
194
|
+
end
|
195
|
+
else
|
196
|
+
debug { " --- No output" }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
out
|
201
|
+
end
|
202
|
+
|
203
|
+
def run_command_internal(command)
|
204
|
+
Open3.popen3(*command) do |i, o, e, t|
|
205
|
+
raise StandardError, e.read unless (t ? t.value : $?).success?
|
206
|
+
o.read
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'librarian/helpers/debug'
|
2
|
+
require 'librarian/support/abstract_method'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
module Source
|
6
|
+
# Requires that the including source class have methods:
|
7
|
+
# #path
|
8
|
+
# #environment
|
9
|
+
module Local
|
10
|
+
|
11
|
+
include Helpers::Debug
|
12
|
+
include Support::AbstractMethod
|
13
|
+
|
14
|
+
abstract_method :path, :fetch_version, :fetch_dependencies
|
15
|
+
|
16
|
+
def manifests(name)
|
17
|
+
manifest = Manifest.new(self, name)
|
18
|
+
[manifest].compact
|
19
|
+
end
|
20
|
+
|
21
|
+
def manifest(name, version, dependencies)
|
22
|
+
manifest = Manifest.new(self, name)
|
23
|
+
manifest.version = version
|
24
|
+
manifest.dependencies = dependencies
|
25
|
+
manifest
|
26
|
+
end
|
27
|
+
|
28
|
+
def manifest_search_paths(name)
|
29
|
+
@manifest_search_paths ||= { }
|
30
|
+
@manifest_search_paths[name] ||= begin
|
31
|
+
cache!
|
32
|
+
paths = [filesystem_path, filesystem_path.join(name)]
|
33
|
+
paths.select{|s| s.exist?}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def found_path(name)
|
38
|
+
@_found_paths ||= { }
|
39
|
+
@_found_paths[name] ||= begin
|
40
|
+
paths = manifest_search_paths(name)
|
41
|
+
paths.find{|p| manifest?(name, p)}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
abstract_method :manifest? # (name, path) -> boolean
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'librarian/source/local'
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
module Source
|
5
|
+
class Path
|
6
|
+
|
7
|
+
include Local
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
LOCK_NAME = 'PATH'
|
12
|
+
|
13
|
+
def lock_name
|
14
|
+
LOCK_NAME
|
15
|
+
end
|
16
|
+
|
17
|
+
def from_lock_options(environment, options)
|
18
|
+
new(environment, options[:remote], options.reject{|k, v| k == :remote})
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_spec_args(environment, path, options)
|
22
|
+
recognized_options = []
|
23
|
+
unrecognized_options = options.keys - recognized_options
|
24
|
+
unrecognized_options.empty? or raise Error, "unrecognized options: #{unrecognized_options.join(", ")}"
|
25
|
+
|
26
|
+
new(environment, path, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_accessor :environment
|
32
|
+
private :environment=
|
33
|
+
attr_reader :path
|
34
|
+
|
35
|
+
def initialize(environment, path, options)
|
36
|
+
self.environment = environment
|
37
|
+
@path = path
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
path.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def ==(other)
|
45
|
+
other &&
|
46
|
+
self.class == other.class &&
|
47
|
+
self.path == other.path
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_spec_args
|
51
|
+
[path.to_s, {}]
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_lock_options
|
55
|
+
{:remote => path}
|
56
|
+
end
|
57
|
+
|
58
|
+
def pinned?
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
def unpin!
|
63
|
+
end
|
64
|
+
|
65
|
+
def cache!
|
66
|
+
end
|
67
|
+
|
68
|
+
def filesystem_path
|
69
|
+
@filesystem_path ||= Pathname.new(path).expand_path(environment.project_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'librarian/helpers'
|
2
|
+
require 'librarian/helpers/debug'
|
3
|
+
|
4
|
+
require 'librarian/manifest_set'
|
5
|
+
require 'librarian/resolution'
|
6
|
+
require 'librarian/spec'
|
7
|
+
|
8
|
+
module Librarian
|
9
|
+
class SpecChangeSet
|
10
|
+
|
11
|
+
include Helpers::Debug
|
12
|
+
|
13
|
+
attr_accessor :environment
|
14
|
+
private :environment=
|
15
|
+
attr_reader :spec, :lock
|
16
|
+
|
17
|
+
def initialize(environment, spec, lock)
|
18
|
+
self.environment = environment
|
19
|
+
raise TypeError, "can't convert #{spec.class} into #{Spec}" unless Spec === spec
|
20
|
+
raise TypeError, "can't convert #{lock.class} into #{Resolution}" unless Resolution === lock
|
21
|
+
@spec, @lock = spec, lock
|
22
|
+
end
|
23
|
+
|
24
|
+
def same?
|
25
|
+
@same ||= spec.dependencies.sort_by{|d| d.name} == lock.dependencies.sort_by{|d| d.name}
|
26
|
+
end
|
27
|
+
|
28
|
+
def changed?
|
29
|
+
!same?
|
30
|
+
end
|
31
|
+
|
32
|
+
def spec_dependencies
|
33
|
+
@spec_dependencies ||= spec.dependencies
|
34
|
+
end
|
35
|
+
def spec_dependency_names
|
36
|
+
@spec_dependency_names ||= Set.new(spec_dependencies.map{|d| d.name})
|
37
|
+
end
|
38
|
+
def spec_dependency_index
|
39
|
+
@spec_dependency_index ||= Hash[spec_dependencies.map{|d| [d.name, d]}]
|
40
|
+
end
|
41
|
+
|
42
|
+
def lock_dependencies
|
43
|
+
@lock_dependencies ||= lock.dependencies
|
44
|
+
end
|
45
|
+
def lock_dependency_names
|
46
|
+
@lock_dependency_names ||= Set.new(lock_dependencies.map{|d| d.name})
|
47
|
+
end
|
48
|
+
def lock_dependency_index
|
49
|
+
@lock_dependency_index ||= Hash[lock_dependencies.map{|d| [d.name, d]}]
|
50
|
+
end
|
51
|
+
|
52
|
+
def lock_manifests
|
53
|
+
@lock_manifests ||= lock.manifests
|
54
|
+
end
|
55
|
+
def lock_manifests_index
|
56
|
+
@lock_manifests_index ||= ManifestSet.new(lock_manifests).to_hash
|
57
|
+
end
|
58
|
+
|
59
|
+
def removed_dependency_names
|
60
|
+
@removed_dependency_names ||= lock_dependency_names - spec_dependency_names
|
61
|
+
end
|
62
|
+
|
63
|
+
# A dependency which is deleted from the specfile will, in the general case,
|
64
|
+
# be removed conservatively. This means it might not actually be removed.
|
65
|
+
# But if the dependency originally declared a source which is now non-
|
66
|
+
# default, it must be removed, even if another dependency has a transitive
|
67
|
+
# dependency on the one that was removed (which is the scenario in which
|
68
|
+
# a conservative removal would not remove it). In this case, we must also
|
69
|
+
# remove it explicitly so that it can be re-resolved from the default
|
70
|
+
# source.
|
71
|
+
def explicit_removed_dependency_names
|
72
|
+
@explicit_removed_dependency_names ||= removed_dependency_names.reject do |name|
|
73
|
+
lock_manifest = lock_manifests_index[name]
|
74
|
+
lock_manifest.source == spec.source
|
75
|
+
end.to_set
|
76
|
+
end
|
77
|
+
|
78
|
+
def added_dependency_names
|
79
|
+
@added_dependency_names ||= spec_dependency_names - lock_dependency_names
|
80
|
+
end
|
81
|
+
|
82
|
+
def nonmatching_added_dependency_names
|
83
|
+
@nonmatching_added_dependency_names ||= added_dependency_names.reject do |name|
|
84
|
+
spec_dependency = spec_dependency_index[name]
|
85
|
+
lock_manifest = lock_manifests_index[name]
|
86
|
+
if lock_manifest
|
87
|
+
matching = true
|
88
|
+
matching &&= spec_dependency.satisfied_by?(lock_manifest)
|
89
|
+
matching &&= spec_dependency.source == lock_manifest.source
|
90
|
+
matching
|
91
|
+
else
|
92
|
+
false
|
93
|
+
end
|
94
|
+
end.to_set
|
95
|
+
end
|
96
|
+
|
97
|
+
def common_dependency_names
|
98
|
+
@common_dependency_names ||= lock_dependency_names & spec_dependency_names
|
99
|
+
end
|
100
|
+
|
101
|
+
def changed_dependency_names
|
102
|
+
@changed_dependency_names ||= common_dependency_names.reject do |name|
|
103
|
+
spec_dependency = spec_dependency_index[name]
|
104
|
+
lock_dependency = lock_dependency_index[name]
|
105
|
+
lock_manifest = lock_manifests_index[name]
|
106
|
+
same = true
|
107
|
+
same &&= spec_dependency.satisfied_by?(lock_manifest)
|
108
|
+
same &&= spec_dependency.source == lock_dependency.source
|
109
|
+
same
|
110
|
+
end.to_set
|
111
|
+
end
|
112
|
+
|
113
|
+
def deep_keep_manifest_names
|
114
|
+
@deep_keep_manifest_names ||= begin
|
115
|
+
lock_dependency_names - (
|
116
|
+
removed_dependency_names +
|
117
|
+
changed_dependency_names +
|
118
|
+
nonmatching_added_dependency_names
|
119
|
+
)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def shallow_strip_manifest_names
|
124
|
+
@shallow_strip_manifest_names ||= begin
|
125
|
+
explicit_removed_dependency_names + changed_dependency_names
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def inspect
|
130
|
+
Helpers.strip_heredoc(<<-INSPECT)
|
131
|
+
<##{self.class.name}:
|
132
|
+
Removed: #{removed_dependency_names.to_a.join(", ")}
|
133
|
+
ExplicitRemoved: #{explicit_removed_dependency_names.to_a.join(", ")}
|
134
|
+
Added: #{added_dependency_names.to_a.join(", ")}
|
135
|
+
NonMatchingAdded: #{nonmatching_added_dependency_names.to_a.join(", ")}
|
136
|
+
Changed: #{changed_dependency_names.to_a.join(", ")}
|
137
|
+
DeepKeep: #{deep_keep_manifest_names.to_a.join(", ")}
|
138
|
+
ShallowStrip: #{shallow_strip_manifest_names.to_a.join(", ")}
|
139
|
+
>
|
140
|
+
INSPECT
|
141
|
+
end
|
142
|
+
|
143
|
+
# Returns an array of those manifests from the previous spec which should be kept,
|
144
|
+
# based on inspecting the new spec against the locked resolution from the previous spec.
|
145
|
+
def analyze
|
146
|
+
@analyze ||= begin
|
147
|
+
debug { "Analyzing spec and lock:" }
|
148
|
+
|
149
|
+
if same?
|
150
|
+
debug { " Same!" }
|
151
|
+
return lock.manifests
|
152
|
+
end
|
153
|
+
|
154
|
+
debug { " Removed:" } ; removed_dependency_names.each { |name| debug { " #{name}" } }
|
155
|
+
debug { " ExplicitRemoved:" } ; explicit_removed_dependency_names.each { |name| debug { " #{name}" } }
|
156
|
+
debug { " Added:" } ; added_dependency_names.each { |name| debug { " #{name}" } }
|
157
|
+
debug { " NonMatchingAdded:" } ; nonmatching_added_dependency_names.each { |name| debug { " #{name}" } }
|
158
|
+
debug { " Changed:" } ; changed_dependency_names.each { |name| debug { " #{name}" } }
|
159
|
+
debug { " DeepKeep:" } ; deep_keep_manifest_names.each { |name| debug { " #{name}" } }
|
160
|
+
debug { " ShallowStrip:" } ; shallow_strip_manifest_names.each { |name| debug { " #{name}" } }
|
161
|
+
|
162
|
+
manifests = ManifestSet.new(lock_manifests)
|
163
|
+
manifests.deep_keep!(deep_keep_manifest_names)
|
164
|
+
manifests.shallow_strip!(shallow_strip_manifest_names)
|
165
|
+
manifests.to_a
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|