From 6590a1eeffbcb9f21dbec6a086f7707a000a9f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20Sowi=C5=84ski?= Date: Mon, 20 Mar 2017 20:14:50 +0100 Subject: [PATCH] Wrap symlink and regular conflicts into one case This way we're not duplicating collision-related code. --- lib/homesick/actions/file_actions.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/homesick/actions/file_actions.rb b/lib/homesick/actions/file_actions.rb index 6a5c26f..2831486 100644 --- a/lib/homesick/actions/file_actions.rb +++ b/lib/homesick/actions/file_actions.rb @@ -63,18 +63,14 @@ module Homesick case action when :identical say_status :identical, destination.expand_path, :blue - when :symlink_conflict - say_status :conflict, - "#{destination} exists and points to #{destination.readlink}", - :red - - if collision_accepted?(destination, source) - FileUtils.rm destination - FileUtils.ln_s source, destination, force: true unless options[:pretend] + when :symlink_conflict, :conflict + if action == :conflict + say_status :conflict, "#{destination} exists", :red + else + say_status :conflict, + "#{destination} exists and points to #{destination.readlink}", + :red end - when :conflict - say_status :conflict, "#{destination} exists", :red - if collision_accepted?(destination, source) FileUtils.rm_r destination, force: true unless options[:pretend] FileUtils.ln_s source, destination, force: true unless options[:pretend]