Added ability for methods to be overrode, through the pretend and quiet

options, skipping their default behaviour if so.
This commit is contained in:
Jeremy Cook
2014-04-20 10:52:30 -04:00
parent b5138bcdd1
commit d4f9633a0c
5 changed files with 67 additions and 51 deletions

View File

@@ -12,12 +12,12 @@ module Homesick
FileUtils.mkdir_p destination.dirname
if destination.directory?
say_status :exist, destination.expand_path, :blue unless options[:quiet]
say_status :exist, destination.expand_path, :blue
else
say_status 'git clone',
"#{repo} to #{destination.expand_path}",
:green unless options[:quiet]
system "git clone -q --config push.default=upstream --recursive #{repo} #{destination}" unless options[:pretend]
:green
system "git clone -q --config push.default=upstream --recursive #{repo} #{destination}"
end
end
@@ -26,10 +26,10 @@ module Homesick
inside path do
if path.join('.git').exist?
say_status 'git init', 'already initialized', :blue unless options[:quiet]
say_status 'git init', 'already initialized', :blue
else
say_status 'git init', '' unless options[:quiet]
system 'git init >/dev/null' unless options[:pretend]
say_status 'git init', ''
system 'git init >/dev/null'
end
end
end
@@ -39,55 +39,55 @@ module Homesick
existing_remote = nil if existing_remote == ''
if existing_remote
say_status 'git remote', "#{name} already exists", :blue unless options[:quiet]
say_status 'git remote', "#{name} already exists", :blue
else
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
system "git remote add #{name} #{url}" unless options[:pretend]
say_status 'git remote', "add #{name} #{url}"
system "git remote add #{name} #{url}"
end
end
def git_submodule_init(config = {})
say_status 'git submodule', 'init', :green unless options[:quiet]
system 'git submodule --quiet init' unless options[:pretend]
say_status 'git submodule', 'init', :green
system 'git submodule --quiet init'
end
def git_submodule_update(config = {})
say_status 'git submodule', 'update', :green unless options[:quiet]
system 'git submodule --quiet update --init --recursive >/dev/null 2>&1' unless options[:pretend]
say_status 'git submodule', 'update', :green
system 'git submodule --quiet update --init --recursive >/dev/null 2>&1'
end
def git_pull(config = {})
say_status 'git pull', '', :green unless options[:quiet]
system 'git pull --quiet' unless options[:pretend]
say_status 'git pull', '', :green
system 'git pull --quiet'
end
def git_push(config = {})
say_status 'git push', '', :green unless options[:quiet]
system 'git push' unless options[:pretend]
say_status 'git push', '', :green
system 'git push'
end
def git_commit_all(config = {})
say_status 'git commit all', '', :green unless options[:quiet]
say_status 'git commit all', '', :green
if config[:message]
system "git commit -a -m '#{config[:message]}'" unless options[:pretend]
system "git commit -a -m '#{config[:message]}'"
else
system 'git commit -v -a' unless options[:pretend]
system 'git commit -v -a'
end
end
def git_add(file, config = {})
say_status 'git add file', '', :green unless options[:quiet]
system "git add '#{file}'" unless options[:pretend]
say_status 'git add file', '', :green
system "git add '#{file}'"
end
def git_status(config = {})
say_status 'git status', '', :green unless options[:quiet]
system 'git status' unless options[:pretend]
say_status 'git status', '', :green
system 'git status'
end
def git_diff(config = {})
say_status 'git diff', '', :green unless options[:quiet]
system 'git diff' unless options[:pretend]
say_status 'git diff', '', :green
system 'git diff'
end
end
end