From 12d7fe0a63f04bcc9c351535aac2462765d984df Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 18 Apr 2016 18:25:46 -0500 Subject: [Definition] Fix lockfiles_equal? regexp for multiple substitutions --- lib/bundler/definition.rb | 9 +++++---- lib/bundler/lockfile_parser.rb | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/bundler') 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 -- cgit v1.2.3