Skip to content

Commit

Permalink
As per issue rubygems#842, store a hash of Gemfile to avoid rerunning…
Browse files Browse the repository at this point in the history
… unnecessary resolve against locally available gems if Gemfile has not changed.
  • Loading branch information
Sean Grove authored and Andre Arko and Terence Lee committed Mar 16, 2011
1 parent 814de81 commit 48758f9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,24 @@ def resolve
source_requirements[dep.name] = dep.source.specs
end

# Run a resolve against the locally available gems
last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve)
end
# Only run a resolve against the locally available gems if Gemfile has changed
# since the last resolve
return last_resolve unless gemfile_changed?

# If it's changed, update hash and rerun resolve
Bundler.settings[:gemfile_hash] = gemfile_hash
last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve) end
end
end

def gemfile_changed?
Digest::MD5.hexdigest(File.read(Bundler.default_gemfile)) == Bundler.settings[:gemfile_hash]
end

def index
@index ||= Index.build do |idx|
@sources.each do |s|
idx.use s.specs(@dependencies)
idx.use s.specs
end
end
end
Expand Down

0 comments on commit 48758f9

Please sign in to comment.