Skip to content

Commit

Permalink
Persist the new rubygem sources to the lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche authored and wycats committed Aug 29, 2010
1 parent fb6a5e5 commit 02ec0fe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/bundler/definition.rb
Expand Up @@ -293,6 +293,13 @@ def pretty_dep(dep, source = false)
end

def converge_sources
locked_gem = @locked_sources.find { |s| Source::Rubygems === s }
actual_gem = @sources.find { |s| Source::Rubygems === s }

if locked_gem && actual_gem
locked_gem.merge_remotes actual_gem
end

@sources.map! do |source|
@locked_sources.find { |s| s == source } || source
end
Expand Down
7 changes: 7 additions & 0 deletions lib/bundler/source.rb
Expand Up @@ -129,6 +129,13 @@ def add_remote(source)
@remotes << normalize_uri(source)
end

def merge_remotes(source)
@remotes = []
source.remotes.each do |r|
add_remote r.to_s
end
end

private

def cached_gem(spec)
Expand Down
31 changes: 30 additions & 1 deletion spec/install/gems/flex_spec.rb
Expand Up @@ -220,7 +220,7 @@
G

gemfile <<-G
source "file:://#{gem_repo1}"
source "file://#{gem_repo1}"
gem "rack", "0.9.1"
gem "rack-obama"
G
Expand All @@ -240,4 +240,33 @@
bundle "update rack"
end
end

describe "when adding a new source" do
it "updates the lockfile" do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
install_gemfile <<-G
source "file://#{gem_repo1}"
source "file://#{gem_repo2}"
gem "rack"
G

lockfile_should_be <<-L
GEM
remote: file:#{gem_repo1}/
remote: file:#{gem_repo2}/
specs:
rack (1.0.0)
PLATFORMS
ruby
DEPENDENCIES
rack
L
end
end
end

0 comments on commit 02ec0fe

Please sign in to comment.