Permalink
Browse files

Add track and no-track option to checkout -b command

  • Loading branch information...
1 parent 1825afd commit 6466c54089eb46ccc489fcf0693e25259806e777 @kmnk committed Jul 10, 2013
Showing with 28 additions and 2 deletions.
  1. +8 −1 autoload/giti/checkout.vim
  2. +20 −1 test/autoload/giti/test_checkout.vim
@@ -39,7 +39,14 @@ function! giti#checkout#create(param)"{{{
let start_point = giti#input('start-point (optional) : ')
endif
- return giti#system('checkout -b ' . name . ' ' . start_point)
+ let track = ''
+ if exists('a:param.track')
+ let track = a:param.track is 1 ? '--track'
+\ : a:param.track is 0 ? '--no-track'
+\ : ''
+ endif
+
+ return giti#system('checkout -b ' . track . ' ' . name . ' ' . start_point)
endfunction"}}}
" local functions {{{
@@ -34,7 +34,26 @@ function! s:tc.test_create()"{{{
\ giti#checkout#create({'name' : 'hoge', 'start_point' : 'fuga'}),
\ 'mocked_system'
\ )
- call self.assert_equal('checkout -b hoge fuga', b:system_called_with)
+ call self.assert_equal('checkout -b hoge fuga', b:system_called_with)
+
+ call self.assert_equal(
+\ giti#checkout#create({'name' : 'hoge', 'start_point' : 'fuga', 'track' : 1}),
+\ 'mocked_system'
+\ )
+ call self.assert_equal('checkout -b --track hoge fuga', b:system_called_with)
+
+ call self.assert_equal(
+\ giti#checkout#create({'name' : 'hoge', 'start_point' : 'fuga', 'track' : 0}),
+\ 'mocked_system'
+\ )
+ call self.assert_equal('checkout -b --no-track hoge fuga', b:system_called_with)
+
+ call self.assert_equal(
+\ giti#checkout#create({'name' : 'hoge', 'start_point' : 'fuga', 'track' : 'hoge'}),
+\ 'mocked_system'
+\ )
+ call self.assert_equal('checkout -b hoge fuga', b:system_called_with)
+
call self.assert_throw('E118', 'call giti#checkout#create("", "")')
call self.assert_throw('E119', 'call giti#checkout#create()')
endfunction"}}}

0 comments on commit 6466c54

Please sign in to comment.