From e48d374bf6d44186f794d689160da40b04453155 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 8 Dec 2009 02:26:19 -0800 Subject: [PATCH] basic `hub install ` support --- lib/hub/commands.rb | 20 ++++++++++++++++++++ test/install_test.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/install_test.rb diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index fbd8b02f..44ce83bc 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -80,6 +80,26 @@ module Hub end end + def install(args) + shells = { + 'sh' => 'alias git=hub', + 'bash' => 'alias git=hub', + 'zsh' => 'alias git=hub', + 'csh' => 'alias git hub', + 'fish' => 'alias git hub' + } + + shell = args[1] + + if shells[shell] + puts shells[shell] + else + abort "fatal: never heard of `#{shell}'" + end + + exit + end + # $ hub version # > git version # (print hub version) diff --git a/test/install_test.rb b/test/install_test.rb new file mode 100644 index 00000000..ac422886 --- /dev/null +++ b/test/install_test.rb @@ -0,0 +1,28 @@ +$LOAD_PATH.unshift File.dirname(__FILE__) +require 'helper' + +class InstallTest < Test::Unit::TestCase + def test_install_bash + assert_equal "alias git=hub\n", hub("install bash") + end + + def test_install_sh + assert_equal "alias git=hub\n", hub("install sh") + end + + def test_install_zsh + assert_equal "alias git=hub\n", hub("install zsh") + end + + def test_install_csh + assert_equal "alias git hub\n", hub("install csh") + end + + def test_install_fish + assert_equal "alias git hub\n", hub("install fish") + end + + def test_install_blah + assert_equal "fatal: never heard of `blah'\n", hub("install blah") + end +end -- GitLab