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

Commit

Permalink
[Source::Path] Don’t store cache paths in the lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Feb 11, 2017
1 parent e059bbf commit 11eb4ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/bundler/source/path.rb
Expand Up @@ -4,10 +4,12 @@ class Source
class Path < Source
autoload :Installer, "bundler/source/path/installer"

attr_reader :path, :options, :root_path
attr_reader :path, :options, :root_path, :original_path
attr_writer :name
attr_accessor :version

protected :original_path

DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze

def initialize(options)
Expand Down Expand Up @@ -61,7 +63,7 @@ def hash

def eql?(other)
return unless other.class == self.class
expanded_path == expand(other.path) &&
expand(@original_path) == expand(other.original_path) &&
version == other.version
end

Expand Down Expand Up @@ -130,8 +132,8 @@ def expand(somepath)
end

def lockfile_path
return relative_path if path.absolute?
expand(path).relative_path_from(Bundler.root)
return relative_path(original_path) if original_path.absolute?
expand(original_path).relative_path_from(Bundler.root)
end

def app_cache_path(custom_path = nil)
Expand Down Expand Up @@ -186,7 +188,7 @@ def load_spec_files
index
end

def relative_path
def relative_path(path = self.path)
if path.to_s.start_with?(root_path.to_s)
return path.relative_path_from(root_path)
end
Expand Down
30 changes: 30 additions & 0 deletions spec/lock/lockfile_spec.rb
Expand Up @@ -600,6 +600,36 @@
G
end

it "serializes pinned path sources to the lockfile even when packaging" do
build_lib "foo"

install_gemfile! <<-G
gem "foo", :path => "#{lib_path("foo-1.0")}"
G

bundle! "package --all"
bundle! "install --local"

lockfile_should_be <<-G
PATH
remote: #{lib_path("foo-1.0")}
specs:
foo (1.0)
GEM
specs:
PLATFORMS
#{generic_local_platform}
DEPENDENCIES
foo!
BUNDLED WITH
#{Bundler::VERSION}
G
end

it "sorts serialized sources by type" do
build_lib "foo"
bar = build_git "bar"
Expand Down

0 comments on commit 11eb4ec

Please sign in to comment.