From f55828f1d45ee50dacf163f25df75bf1c0a5b2bc Mon Sep 17 00:00:00 2001 From: Jeremy Cook Date: Tue, 22 Apr 2014 20:54:05 -0400 Subject: [PATCH] Fixing a bug that breaks the handling of collisions. --- lib/homesick/actions/file_actions.rb | 2 +- lib/homesick/utils.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/homesick/actions/file_actions.rb b/lib/homesick/actions/file_actions.rb index e4d4a37..52fc2e6 100644 --- a/lib/homesick/actions/file_actions.rb +++ b/lib/homesick/actions/file_actions.rb @@ -75,7 +75,7 @@ module Homesick when :conflict say_status :conflict, "#{destination} exists", :red unless options[:quiet] - if collision_accepted? + if collision_accepted?(destination) FileUtils.rm_r destination, force: true unless options[:pretend] FileUtils.ln_s source, destination, force: true unless options[:pretend] end diff --git a/lib/homesick/utils.rb b/lib/homesick/utils.rb index 4a5a6c8..d746694 100644 --- a/lib/homesick/utils.rb +++ b/lib/homesick/utils.rb @@ -132,7 +132,8 @@ module Homesick first_p.mtime > second_p.mtime && !first_p.symlink? end - def collision_accepted? + def collision_accepted?(destination) + fail "Argument must be an instance of Pathname, #{destination.class.name} given" unless destination.instance_of?(Pathname) options[:force] || shell.file_collision(destination) { source } end