lib/berkshelf/resolver.rb in berkshelf-2.0.4 vs lib/berkshelf/resolver.rb in berkshelf-2.0.5

- old
+ new

@@ -152,21 +152,30 @@ # CookbookSource. # # @return [Boolean] def use_source(source) name = source.name - constraint = source.version_constraint + locked = source.locked_version location = source.location + # Lock the version constraint if a locked version was supplied + source.version_constraint = Solve::Constraint.new(locked.to_s) if locked + constraint = source.version_constraint + if source.downloaded? cached = source.cached_cookbook location.validate_cached(cached) Berkshelf.formatter.use(name, cached.version, location) true elsif location.is_a?(GitLocation) false else - cached = downloader.cookbook_store.satisfy(name, constraint) + # If a locked version if specified, it must exist + if locked + cached = downloader.cookbook_store.cookbook(name, locked) + else + cached = downloader.cookbook_store.satisfy(name, constraint) + end if cached get_source(source).cached_cookbook = cached Berkshelf.formatter.use(name, cached.version) true