lib/bundler/definition.rb in bundler-0.9.1 vs lib/bundler/definition.rb in bundler-0.9.2

- old
+ new

@@ -1,5 +1,7 @@ +require "digest/sha1" + module Bundler class Definition def self.from_gemfile(gemfile) gemfile = Pathname.new(gemfile).expand_path @@ -11,11 +13,17 @@ end def self.from_lock(lockfile) # gemfile_definition = from_gemfile(nil) locked_definition = Locked.new(YAML.load_file(lockfile)) - # raise GemfileError unless gemfile_definition.equivalent?(locked_definition) + + # TODO: Switch to using equivalent? + hash = Digest::SHA1.hexdigest(File.read("#{Bundler.root}/Gemfile")) + unless locked_definition.hash == hash + raise GemfileError, "You changed your Gemfile after locking. Please relock using `gem lock`" + end + locked_definition end attr_reader :dependencies, :sources @@ -51,9 +59,13 @@ # end class Locked < Definition def initialize(details) @details = details + end + + def hash + @details["hash"] end def sources @sources ||= @details["sources"].map do |args| name, options = args.to_a.flatten