Coding standards fixes based off of Rubocop and minor edits to make
logic flow easier to understand.
This commit is contained in:
@@ -3,16 +3,14 @@ module Homesick
|
||||
module Actions
|
||||
# File-related helper methods for Homesick
|
||||
module FileActions
|
||||
def mv(source, destination, config = {})
|
||||
def mv(source, destination)
|
||||
source = Pathname.new(source)
|
||||
destination = Pathname.new(destination + source.basename)
|
||||
|
||||
if destination.exist?
|
||||
case
|
||||
when destination.exist? && (options[:force] || shell.file_collision(destination) { source })
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
|
||||
FileUtils.mv source, destination if (options[:force] || shell.file_collision(destination) { source }) && !options[:pretend]
|
||||
FileUtils.mv source, destination unless options[:pretend]
|
||||
else
|
||||
# this needs some sort of message here.
|
||||
FileUtils.mv source, destination unless options[:pretend]
|
||||
end
|
||||
end
|
||||
@@ -43,7 +41,7 @@ module Homesick
|
||||
FileUtils.rm_r dir
|
||||
end
|
||||
|
||||
def ln_s(source, destination, config = {})
|
||||
def ln_s(source, destination)
|
||||
source = Pathname.new(source)
|
||||
destination = Pathname.new(destination)
|
||||
FileUtils.mkdir_p destination.dirname
|
||||
|
||||
@@ -14,7 +14,7 @@ module Homesick
|
||||
def git_version_correct?
|
||||
info = `git --version`.scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map(&:to_i)
|
||||
return false unless info.count == 3
|
||||
current_version = Hash[ [:major, :minor, :patch].zip(info) ]
|
||||
current_version = Hash[[:major, :minor, :patch].zip(info)]
|
||||
return true if current_version.eql?(MIN_VERSION)
|
||||
return true if current_version[:major] > MIN_VERSION[:major]
|
||||
return true if current_version[:major] == MIN_VERSION[:major] && current_version[:minor] > MIN_VERSION[:minor]
|
||||
@@ -27,7 +27,7 @@ module Homesick
|
||||
config ||= {}
|
||||
destination = config[:destination] || File.basename(repo, '.git')
|
||||
|
||||
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
|
||||
destination = Pathname.new(destination) unless destination.is_a?(Pathname)
|
||||
FileUtils.mkdir_p destination.dirname
|
||||
|
||||
if destination.directory?
|
||||
@@ -65,22 +65,22 @@ module Homesick
|
||||
end
|
||||
end
|
||||
|
||||
def git_submodule_init(config = {})
|
||||
def git_submodule_init
|
||||
say_status 'git submodule', 'init', :green
|
||||
system 'git submodule --quiet init'
|
||||
end
|
||||
|
||||
def git_submodule_update(config = {})
|
||||
def git_submodule_update
|
||||
say_status 'git submodule', 'update', :green
|
||||
system 'git submodule --quiet update --init --recursive >/dev/null 2>&1'
|
||||
end
|
||||
|
||||
def git_pull(config = {})
|
||||
def git_pull
|
||||
say_status 'git pull', '', :green
|
||||
system 'git pull --quiet'
|
||||
end
|
||||
|
||||
def git_push(config = {})
|
||||
def git_push
|
||||
say_status 'git push', '', :green
|
||||
system 'git push'
|
||||
end
|
||||
@@ -88,23 +88,23 @@ module Homesick
|
||||
def git_commit_all(config = {})
|
||||
say_status 'git commit all', '', :green
|
||||
if config[:message]
|
||||
system %Q(git commit -a -m "#{config[:message]}")
|
||||
system %(git commit -a -m "#{config[:message]}")
|
||||
else
|
||||
system 'git commit -v -a'
|
||||
end
|
||||
end
|
||||
|
||||
def git_add(file, config = {})
|
||||
def git_add(file)
|
||||
say_status 'git add file', '', :green
|
||||
system "git add '#{file}'"
|
||||
end
|
||||
|
||||
def git_status(config = {})
|
||||
def git_status
|
||||
say_status 'git status', '', :green
|
||||
system 'git status'
|
||||
end
|
||||
|
||||
def git_diff(config = {})
|
||||
def git_diff
|
||||
say_status 'git diff', '', :green
|
||||
system 'git diff'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user