summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-05-26 11:15:03 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-14 10:15:47 -0500
commite274d9fe47a0f1801761e4646ce5df32df6033ac (patch)
tree7a923fa48f962c769d512046d0bae34098b23741
parentddcca6254cc4e63cbb25b78f8ec93462fa56249c (diff)
downloadbundler-e274d9fe47a0f1801761e4646ce5df32df6033ac.tar.gz
[Pristine] Ensure git gems have added files removed
-rw-r--r--lib/bundler/cli/pristine.rb10
-rw-r--r--spec/commands/pristine_spec.rb17
2 files changed, 19 insertions, 8 deletions
diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb
index 30542b583e..86b7b86eaa 100644
--- a/lib/bundler/cli/pristine.rb
+++ b/lib/bundler/cli/pristine.rb
@@ -10,7 +10,7 @@ module Bundler
gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
- case spec.source
+ case source = spec.source
when Source::Rubygems
cached_gem = spec.cache_file
unless File.exist?(cached_gem)
@@ -19,11 +19,11 @@ module Bundler
end
FileUtils.rm_rf spec.full_gem_path
- spec.source.install(spec, :force => true)
+ source.install(spec, :force => true)
when Source::Git
- git_source = spec.source
- git_source.remote!
- git_source.install(spec, :force => true)
+ source.remote!
+ FileUtils.rm_rf spec.full_gem_path
+ source.install(spec, :force => true)
else
Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index cc01aabbf7..2bf9d46c66 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -52,12 +52,23 @@ RSpec.describe "bundle pristine" do
changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb")
diff = "#Pristine spec changes"
- File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
+ File.open(changed_file, "a") {|f| f.puts diff }
expect(File.read(changed_file)).to include(diff)
- bundle "pristine"
+ bundle! "pristine"
expect(File.read(changed_file)).to_not include(diff)
end
+
+ it "removes added files" do
+ spec = Bundler.definition.specs["foo"].first
+ changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
+
+ FileUtils.touch(changes_txt)
+ expect(changes_txt).to be_file
+
+ bundle! "pristine"
+ expect(changes_txt).not_to be_file
+ end
end
context "when sourced from gemspec" do
@@ -66,7 +77,7 @@ RSpec.describe "bundle pristine" do
changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb")
diff = "#Pristine spec changes"
- File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
+ File.open(changed_file, "a") {|f| f.puts diff }
expect(File.read(changed_file)).to include(diff)
bundle "pristine"