aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-04-18 18:25:46 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-04-18 18:25:46 -0500
commit12d7fe0a63f04bcc9c351535aac2462765d984df (patch)
tree062e31582c4045f8fcd509635dc63e13c93b2a6e /lib/bundler
parent52a1f7ffd1fb8cabaed7990b0b9cf92f351bebfb (diff)
downloadbundler-12d7fe0a63f04bcc9c351535aac2462765d984df.tar.gz
[Definition] Fix lockfiles_equal? regexp for multiple substitutions
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/definition.rb9
-rw-r--r--lib/bundler/lockfile_parser.rb2
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 0b388ebb..7607a472 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -682,10 +682,11 @@ module Bundler
if preserve_new_attributes
attributes_to_ignore = LockfileParser.attributes_to_ignore(@locked_bundler_version)
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")
+ attributes_to_ignore += LockfileParser::ENVIRONMENT_VERSION_ATTRIBUTES
+ pattern = /#{Regexp.union(attributes_to_ignore)}\n(\s{2,}.*\n)+/
+ whitespace_cleanup = /\n{2,}/
+ current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
+ proposed = proposed.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
end
current == proposed
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 1c662edb..3025513f 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -34,6 +34,8 @@ module Bundler
ALL_KNOWN_ATTRIBUTES = ATTRIBUTES_BY_VERSION_INTRODUCED.values.flatten.freeze
+ ENVIRONMENT_VERSION_ATTRIBUTES = [BUNDLED, RUBY].freeze
+
def self.attributes_in_lockfile(lockfile_contents)
lockfile_contents.scan(/^\w[\w ]*$/).uniq
end