Permalink
Browse files

add push -u function and command

  • Loading branch information...
1 parent d3984ae commit a3b2eedc303f663f3be9ca380f57430815559433 @kmnk committed Jul 10, 2012
Showing with 35 additions and 0 deletions.
  1. +6 −0 autoload/giti/push.vim
  2. +6 −0 plugin/giti.vim
  3. +23 −0 test/autoload/giti/test_push.vim
@@ -15,6 +15,12 @@ function! giti#push#run(param)"{{{
return s:run(arg)
endfunction"}}}
+function! giti#push#set_upstream(param)"{{{
+ let arg = a:param
+ let arg.command = 'push -u'
+ return s:run(arg)
+endfunction"}}}
+
function! giti#push#expressly()"{{{
let arg = {}
let arg.command = 'push'
View
@@ -37,6 +37,12 @@ function! s:call_giti_push(arg)"{{{
echo giti#push#run({'repository' : repository, 'refspec' : refspec})
endfunction"}}}
+command! -nargs=* GitiPushWithSettingUpstream call s:call_giti_push_with_setting_upstream(<q-args>)
+function! s:call_giti_push_with_setting_upstream(arg)"{{{
+ let [repository, refspec] = s:map_param(a:arg)
+ echo giti#push#set_upstream({'repository' : repository, 'refspec' : refspec})
+endfunction"}}}
+
command! -nargs=0 GitiPushExpressly call s:call_giti_push_expressly()
function! s:call_giti_push_expressly()"{{{
echo giti#push#expressly()
@@ -28,4 +28,27 @@ function! s:tc.test_run()"{{{
call self.assert_throw('E119', 'call giti#push#run()')
endfunction"}}}
+function! s:tc.test_set_upstream()"{{{
+ call self.assert_equal(
+\ giti#push#set_upstream({
+\ 'repository' : 'hoge',
+\ 'refspec' : 'fuga',
+\ }),
+\ 'mocked_system_with_specifics',
+\ )
+ call self.assert_equal(b:system_with_specifics_called_with,
+\ {'command' : 'push -u hoge fuga', 'with_confirm' : 1})
+ call giti#push#set_upstream({})
+ call self.assert_equal(b:system_with_specifics_called_with,
+\ {'command' : 'push -u ', 'with_confirm' : 1})
+ call giti#push#set_upstream({ 'repository' : 'hoge' })
+ call self.assert_equal(b:system_with_specifics_called_with,
+\ {'command' : 'push -u hoge ', 'with_confirm' : 1})
+ call giti#push#set_upstream({ 'refspec' : 'fuga' })
+ call self.assert_equal(b:system_with_specifics_called_with,
+\ {'command' : 'push -u fuga', 'with_confirm' : 1})
+ call self.assert_throw('E118', 'call giti#push#set_upstream("", "")')
+ call self.assert_throw('E119', 'call giti#push#set_upstream()')
+endfunction"}}}
+
unlet s:tc

0 comments on commit a3b2eed

Please sign in to comment.