Wrap symlink and regular conflicts into one case

This way we're not duplicating collision-related code.
This commit is contained in:
Jacek Sowiński
2017-03-20 20:14:50 +01:00
parent 693ae5f05e
commit 6590a1eeff

View File

@@ -63,18 +63,14 @@ module Homesick
case action case action
when :identical when :identical
say_status :identical, destination.expand_path, :blue say_status :identical, destination.expand_path, :blue
when :symlink_conflict when :symlink_conflict, :conflict
if action == :conflict
say_status :conflict, "#{destination} exists", :red
else
say_status :conflict, say_status :conflict,
"#{destination} exists and points to #{destination.readlink}", "#{destination} exists and points to #{destination.readlink}",
:red :red
if collision_accepted?(destination, source)
FileUtils.rm destination
FileUtils.ln_s source, destination, force: true unless options[:pretend]
end end
when :conflict
say_status :conflict, "#{destination} exists", :red
if collision_accepted?(destination, source) if collision_accepted?(destination, source)
FileUtils.rm_r destination, force: true unless options[:pretend] FileUtils.rm_r destination, force: true unless options[:pretend]
FileUtils.ln_s source, destination, force: true unless options[:pretend] FileUtils.ln_s source, destination, force: true unless options[:pretend]