Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add check for lockfile object
Browse files Browse the repository at this point in the history
  • Loading branch information
agrim123 committed Mar 19, 2018
1 parent 72b344e commit 470d7de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 10 additions & 5 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
@static_gemfile = false

@locked_gems = lockfile
@lockfile = lockfile && lockfile.lockfile
@lockfile_contents = lockfile && lockfile.lockfile_contents || String.new
@locked_bundler_version = lockfile && lockfile.bundler_version
@locked_ruby_version = lockfile && lockfile.ruby_version
@locked_platforms = lockfile && lockfile.platforms || []
@lockfile = lockfile
@lockfile_contents = String.new
@locked_bundler_version = nil
@locked_ruby_version = nil
@locked_platforms = []

if lockfile
@lockfile = lockfile.lockfile
@lockfile_contents = lockfile.lockfile_contents || String.new
@locked_bundler_version = lockfile.bundler_version
@locked_ruby_version = lockfile.ruby_version
@locked_platforms = lockfile.platforms || []
@platforms = @locked_platforms.dup

if unlock != true
Expand Down
5 changes: 5 additions & 0 deletions lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ def github(repo, options = {})
end

def to_definition(lockfile, unlock)
# Convert lockfile to LockfileParser object
if lockfile && !lockfile.instance_of?(LockfileParser)
lockfile = LockfileParser.new(Bundler.read_file(lockfile))
end

Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles).tap do |definition|
definition.static_gemfile = !@dynamic
end
Expand Down
4 changes: 0 additions & 4 deletions lib/bundler/injector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ def inject(gemfile_path, lockfile_path)
# Set conservative versioning to false because we want to let the resolver resolve the version first
builder.eval_gemfile("injected gems", build_gem_lines(false)) if @new_deps.any?

# resolve to see if the new deps broke anything
@definition = builder.to_definition(lockfile_path, {})
@definition.resolve_remotely!

# since nothing broke, we can add those gems to the gemfile
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @new_deps.any?

Expand Down

0 comments on commit 470d7de

Please sign in to comment.