@@ -73,7 +73,7 @@ module Homesick
|
||||
when :conflict
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
|
||||
if collision_accepted?(destination)
|
||||
if collision_accepted?(destination, source)
|
||||
FileUtils.rm_r destination, force: true unless options[:pretend]
|
||||
FileUtils.ln_s source, destination, force: true unless options[:pretend]
|
||||
end
|
||||
|
||||
@@ -25,10 +25,13 @@ module Homesick
|
||||
exit(1)
|
||||
end
|
||||
# Hack in support for diffing symlinks
|
||||
# Also adds support for checking if destination or content is a directory
|
||||
shell_metaclass = class << shell; self; end
|
||||
shell_metaclass.send(:define_method, :show_diff) do |destination, content|
|
||||
destination = Pathname.new(destination)
|
||||
return super unless destination.symlink?
|
||||
content = Pathname.new(content)
|
||||
return 'Unable to create diff: destination or content is a directory' if destination.directory? || content.directory?
|
||||
return super(destination, content) unless destination.symlink?
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{content.expand_path}", :green, true
|
||||
end
|
||||
|
||||
@@ -148,8 +148,8 @@ module Homesick
|
||||
first_p.mtime > second_p.mtime && !first_p.symlink?
|
||||
end
|
||||
|
||||
def collision_accepted?(destination)
|
||||
fail "Argument must be an instance of Pathname, #{destination.class.name} given" unless destination.instance_of?(Pathname)
|
||||
def collision_accepted?(destination, source)
|
||||
fail "Arguments must be instances of Pathname, #{destination.class.name} and #{source.class.name} given" unless destination.instance_of?(Pathname) && source.instance_of?(Pathname)
|
||||
options[:force] || shell.file_collision(destination) { source }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user