summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-04-18 15:00:37 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-04-18 15:00:37 -0500
commit633353775105a7f5d31f4962242ae2f7dc12817c (patch)
treebac50271521be180d085f2fd9438d8a68c8a58af
parente48adc87220c4a44908b7b081ed748462552cb92 (diff)
downloadbundler-633353775105a7f5d31f4962242ae2f7dc12817c.tar.gz
[Definition] Ignore unknown attributes as well
-rw-r--r--lib/bundler/definition.rb10
-rw-r--r--lib/bundler/lockfile_parser.rb12
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 1a78cc4b10..0b388ebbae 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -681,11 +681,11 @@ module Bundler
def lockfiles_equal?(current, proposed, preserve_new_attributes)
if preserve_new_attributes
attributes_to_ignore = LockfileParser.attributes_to_ignore(@locked_bundler_version)
- attributes_to_ignore.each do |attribute_to_ignore|
- pattern = /(\A|\n\n)#{attribute_to_ignore}\n(\s+.*\n)+\n?/m
- current = current.sub(pattern, "\n")
- proposed = proposed.sub(pattern, "\n")
- end
+ attributes_to_ignore += LockfileParser.unknown_attributes_in_lockfile(current)
+ attributes_to_ignore << LockfileParser::BUNDLED
+ pattern = /(\A|\n\n)#{Regexp.union(attributes_to_ignore)}\n(\s{2,}.*\n)+\n?/
+ current = current.gsub(pattern, "\n")
+ proposed = proposed.gsub(pattern, "\n")
end
current == proposed
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 280bcd1c4d..ff5a91710e 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -32,12 +32,22 @@ module Bundler
Gem::Version.create("1.12") => [RUBY].freeze,
}.freeze
+ ALL_KNOWN_ATTRIBUTES = ATTRIBUTES_BY_VERSION_INTRODUCED.values.flatten.freeze
+
+ def self.attributes_in_lockfile(lockfile_contents)
+ lockfile_contents.scan(/^(\W[\W ])$/).uniq
+ end
+
+ def self.unknown_attributes_in_lockfile(lockfile_contents)
+ attributes_in_lockfile(lockfile_contents) - ALL_KNOWN_ATTRIBUTES
+ end
+
def self.attributes_to_ignore(base_version = nil)
base_version &&= base_version.release
base_version ||= Gem::Version.create("1.0")
attributes = []
ATTRIBUTES_BY_VERSION_INTRODUCED.each do |version, introduced|
- next if version > base_version
+ next if version <= base_version
attributes += introduced
end
attributes