From 571c5799e92fbe1c10fd408b6f6d76b73fe8b84f Mon Sep 17 00:00:00 2001 From: Nicolas McCurdy Date: Mon, 6 Jan 2014 21:04:25 -0500 Subject: [PATCH] Swap some if/else statements so the positive case is always first --- lib/homesick/actions.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 239c33e..096aad4 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -10,11 +10,11 @@ class Homesick destination = Pathname.new(destination) unless destination.kind_of?(Pathname) FileUtils.mkdir_p destination.dirname - if !destination.directory? + if destination.directory? + say_status :exist, destination.expand_path, :blue unless options[:quiet] + 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] - else - say_status :exist, destination.expand_path, :blue unless options[:quiet] end end @@ -22,11 +22,11 @@ class Homesick path = Pathname.new(path) inside path do - if !path.join('.git').exist? + if path.join('.git').exist? + say_status 'git init', 'already initialized', :blue unless options[:quiet] + else say_status 'git init', '' unless options[:quiet] system 'git init >/dev/null' unless options[:pretend] - else - say_status 'git init', 'already initialized', :blue unless options[:quiet] end end end @@ -35,11 +35,11 @@ class Homesick existing_remote = `git config remote.#{name}.url`.chomp existing_remote = nil if existing_remote == '' - if !existing_remote + if existing_remote + say_status 'git remote', "#{name} already exists", :blue unless options[:quiet] + else say_status 'git remote', "add #{name} #{url}" unless options[:quiet] system "git remote add #{name} #{url}" unless options[:pretend] - else - say_status 'git remote', "#{name} already exists", :blue unless options[:quiet] end end