From 99760c27afedecc2d87d3dd2b6cecb928a699655 Mon Sep 17 00:00:00 2001 From: David Simon Date: Tue, 25 Jun 2013 16:11:08 -0400 Subject: [PATCH 1/3] 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 ed30af9..0bc33fc 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -161,6 +161,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 ef4ad24..9946ff9 100644 --- a/lib/homesick/actions.rb +++ b/lib/homesick/actions.rb @@ -71,6 +71,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 f949259..173897c 100644 --- a/spec/homesick_spec.rb +++ b/spec/homesick_spec.rb @@ -200,6 +200,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' From 8be3cdb6a036457b8e637727ce7f4afe21b6d29c Mon Sep 17 00:00:00 2001 From: David Simon Date: Wed, 26 Jun 2013 14:29:45 -0400 Subject: [PATCH 2/3] Using DEFAULT_CASTLE_NAME in show_path, diff, status --- lib/homesick.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 0bc33fc..8db424f 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -162,15 +162,15 @@ class Homesick < Thor end desc 'status CASTLE', 'Shows the git status of a castle' - def status(castle) + def status(castle = DEFAULT_CASTLE_NAME) 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) + desc 'diff CASTLE', 'Shows the git diff of uncommitted changes in a castle' + def diff(castle = DEFAULT_CASTLE_NAME) check_castle_existance(castle, 'diff') inside repos_dir.join(castle) do git_diff @@ -178,7 +178,7 @@ class Homesick < Thor end desc 'show_path CASTLE', 'Prints the path of a castle' - def show_path(castle) + def show_path(castle = DEFAULT_CASTLE_DAME) check_castle_existance(castle, 'show_path') say repos_dir.join(castle) end From a68149a87bcaefffbffb730cade015f87fcd713b Mon Sep 17 00:00:00 2001 From: David Simon Date: Wed, 26 Jun 2013 14:34:43 -0400 Subject: [PATCH 3/3] Whoops, fixed typo --- lib/homesick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 8db424f..81b9a05 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -178,7 +178,7 @@ class Homesick < Thor end desc 'show_path CASTLE', 'Prints the path of a castle' - def show_path(castle = DEFAULT_CASTLE_DAME) + def show_path(castle = DEFAULT_CASTLE_NAME) check_castle_existance(castle, 'show_path') say repos_dir.join(castle) end