From 92c61f928e55f3457b0849a78cbbfeb8f1c9d7ad Mon Sep 17 00:00:00 2001 From: David Simon Date: Tue, 25 Jun 2013 16:11:08 -0400 Subject: [PATCH] Added three commands: show_path, status, diff --- lib/homesick.rb | 22 ++++++++++++++++++++++ lib/homesick/actions.rb | 10 ++++++++++ spec/homesick_spec.rb | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/lib/homesick.rb b/lib/homesick.rb index a6480a6..2b7b306 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -162,6 +162,28 @@ class Homesick < Thor end end + desc 'status CASTLE', 'Shows the git status of a castle' + def status(castle) + check_castle_existance(castle, 'status') + inside repos_dir.join(castle) do + git_status + end + end + + desc 'diff CASTLE', 'Shows the git diff of a castle' + def diff(castle) + check_castle_existance(castle, 'diff') + inside repos_dir.join(castle) do + git_diff + end + end + + desc 'show_path CASTLE', 'Prints the path of a castle' + def show_path(castle) + check_castle_existance(castle, 'show_path') + say repos_dir.join(castle) + end + desc 'generate PATH', 'generate a homesick-ready git repo at PATH' def generate(castle) castle = Pathname.new(castle).expand_path diff --git a/lib/homesick/actions.rb b/lib/homesick/actions.rb index 26eb45d..1a6a406 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -72,6 +72,16 @@ class Homesick system "git add #{file}" unless options[:pretend] end + def git_status(config = {}) + say_status 'git status', '', :green unless options[:quiet] + system "git status" unless options[:pretend] + end + + def git_diff(config = {}) + say_status 'git diff', '', :green unless options[:quiet] + system "git diff" unless options[:pretend] + end + def mv(source, destination, config = {}) source = Pathname.new(source) destination = Pathname.new(destination + source.basename) diff --git a/spec/homesick_spec.rb b/spec/homesick_spec.rb index f4037b5..fdea672 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -201,6 +201,28 @@ describe 'homesick' do end end + describe 'status' do + + xit 'needs testing' + + end + + describe 'diff' do + + xit 'needs testing' + + end + + describe 'show_path' do + it 'should say the path of a castle' do + castle = given_castle('castle_repo') + + homesick.should_receive(:say).with(castle.dirname) + + homesick.show_path('castle_repo') + end + end + describe 'pull' do xit 'needs testing'