Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add track and no_track option to checkout#switch method

  • Loading branch information...
commit 93f9cda9ebe516d2ca0b4fabfa252cde99db375c 1 parent 547846e
@kmnk authored
View
2  autoload/giti/branch.vim
@@ -71,7 +71,7 @@ function! giti#branch#create(branch)"{{{
endfunction"}}}
function! giti#branch#switch(branch)"{{{
- return giti#checkout#switch(a:branch)
+ return giti#checkout#switch({'name' : a:branch})
endfunction"}}}
" local function {{{
View
13 autoload/giti/checkout.vim
@@ -14,8 +14,17 @@ function! giti#checkout#run(files)"{{{
return giti#system('checkout -- ' . join(a:files))
endfunction"}}}
-function! giti#checkout#switch(name)"{{{
- return giti#system('checkout ' . a:name)
+function! giti#checkout#switch(param)"{{{
+ let name = a:param.name
+
+ 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 ' . track . ' ' . name)
endfunction"}}}
function! giti#checkout#create(param)"{{{
View
2  autoload/unite/kinds/giti/branch.vim
@@ -29,7 +29,7 @@ function! s:kind.action_table.run.func(candidate)"{{{
let context.input = ''
call unite#start([['giti/branch/new', a:candidate.action__name]], context)
else
- call giti#print(giti#checkout#switch(a:candidate.action__name))
+ call giti#print(giti#checkout#switch({'name' : a:candidate.action__name}))
endif
endfunction"}}}
let s:kind.alias_table.switch = 'run'
View
6 test/autoload/giti/test_branch.vim
@@ -5,8 +5,8 @@ function! s:tc.SETUP()"{{{
let b:checkout_create_called_with = a:param
return 'mocked_checkout_create'
endfunction"}}}
- function! giti#checkout#switch(branch)"{{{
- let b:checkout_switch_called_with = a:branch
+ function! giti#checkout#switch(param)"{{{
+ let b:checkout_switch_called_with = a:param
return 'mocked_checkout_switch'
endfunction"}}}
function! giti#push#delete_remote_branch(branch)"{{{
@@ -97,7 +97,7 @@ endfunction"}}}
function! s:tc.test_switch()"{{{
call self.assert_equal(giti#branch#switch('hoge'), 'mocked_checkout_switch')
- call self.assert_equal(b:checkout_switch_called_with, 'hoge')
+ call self.assert_equal(b:checkout_switch_called_with, {'name' : 'hoge'})
call self.assert_throw('E118', 'call giti#branch#switch("", "")')
call self.assert_throw('E119', 'call giti#branch#switch()')
endfunction"}}}
View
14 test/autoload/giti/test_checkout.vim
@@ -13,8 +13,18 @@ function! s:tc.test_run()"{{{
endfunction"}}}
function! s:tc.test_switch()"{{{
- call self.assert_equal(giti#checkout#switch('hoge'), 'mocked_system')
- call self.assert_equal('checkout hoge', b:system_called_with)
+ call self.assert_equal(giti#checkout#switch({'name' : 'hoge'}), 'mocked_system')
+ call self.assert_equal('checkout hoge', b:system_called_with)
+
+ call self.assert_equal(giti#checkout#switch({'name' : 'hoge', 'track' : 0}), 'mocked_system')
+ call self.assert_equal('checkout --no-track hoge', b:system_called_with)
+
+ call self.assert_equal(giti#checkout#switch({'name' : 'hoge', 'track' : 1}), 'mocked_system')
+ call self.assert_equal('checkout --track hoge', b:system_called_with)
+
+ call self.assert_equal(giti#checkout#switch({'name' : 'hoge', 'track' : 'hoge'}), 'mocked_system')
+ call self.assert_equal('checkout hoge', b:system_called_with)
+
call self.assert_throw('E118', 'call giti#checkout#switch("", "")')
call self.assert_throw('E119', 'call giti#checkout#switch()')
endfunction"}}}
View
6 test/autoload/unite/kinds/giti/test_branch.vim
@@ -24,8 +24,8 @@ function! s:tc.kind_should_have()"{{{
endfunction"}}}
function! s:tc.setup_kind_action_run()"{{{
- function! giti#checkout#switch(name)"{{{
- let b:checkout_switch_called_with = a:name
+ function! giti#checkout#switch(param)"{{{
+ let b:checkout_switch_called_with = a:param
return 'mocked giti#checkout#switch'
endfunction"}}}
endfunction"}}}
@@ -48,7 +48,7 @@ function! s:tc.test_kind_action_run()"{{{
\ }
call self.assert_equal(run.func(candidate), 'mocked giti#checkout#switch')
call self.assert_equal(b:checkout_switch_called_with,
-\ candidate.action__name)
+\ {'name' : candidate.action__name})
let candidate.action__is_new = 1
call self.assert_equal(run.func(candidate), 'mocked unite#start')
Please sign in to comment.
Something went wrong with that request. Please try again.