From cde7989e85963eafa2d9ad1138c019272357b16d Mon Sep 17 00:00:00 2001 From: Joshua Nichols Date: Wed, 31 Mar 2010 23:18:38 -0400 Subject: [PATCH] Fix conflict resolution when destination is a plain file (not a symlink). --- bin/homesick | 2 +- lib/homesick/actions.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/homesick b/bin/homesick index 06e6161..711405d 100755 --- a/bin/homesick +++ b/bin/homesick @@ -2,7 +2,7 @@ require 'pathname' lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path -$LOAD_PATH.unshift.unshift lib.to_s unless $LOAD_PATH.include?(lib.to_s) +$LOAD_PATH.unshift lib.to_s require 'homesick' diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 041f88a..16b2810 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -31,6 +31,12 @@ class Homesick system "ln -sf #{source} #{destination}" unless options[:pretend] end end + elsif destination.exist? + say_status :conflict, "#{destination} exists", :red unless options[:quiet] + + if shell.file_collision(destination) { source } + system "ln -sf #{source} #{destination}" unless options[:pretend] + end else say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green unless options[:quiet] system "ln -s #{source} #{destination}" unless options[:pretend]