Moved code to utils to reduce method complexity.
This commit is contained in:
@@ -24,18 +24,7 @@ module Homesick
|
||||
say_status :error, "Git version >= #{Homesick::Actions::GitActions::STRING} must be installed to use Homesick", :red
|
||||
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, source|
|
||||
destination = Pathname.new(destination)
|
||||
source = Pathname.new(source)
|
||||
return 'Unable to create diff: destination or content is a directory' if destination.directory? || source.directory?
|
||||
return super(destination, File.binread(source)) unless destination.symlink?
|
||||
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{source.expand_path}", :green, true
|
||||
end
|
||||
configure_symlinks_diff
|
||||
end
|
||||
|
||||
desc 'clone URI CASTLE_NAME', 'Clone +uri+ as a castle with name CASTLE_NAME for homesick'
|
||||
|
||||
@@ -212,5 +212,20 @@ module Homesick
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def configure_symlinks_diff
|
||||
# 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, source|
|
||||
destination = Pathname.new(destination)
|
||||
source = Pathname.new(source)
|
||||
return 'Unable to create diff: destination or content is a directory' if destination.directory? || source.directory?
|
||||
return super(destination, File.binread(source)) unless destination.symlink?
|
||||
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{source.expand_path}", :green, true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user