Skip to content

Commit

Permalink
rebase with confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnk committed Jul 13, 2012
1 parent b9c1a0b commit 59e1f4c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
15 changes: 11 additions & 4 deletions autoload/giti/rebase.vim
Expand Up @@ -10,10 +10,17 @@ set cpo&vim
" }}}

function! giti#rebase#run(param)"{{{
return giti#system(printf('rebase %s %s',
\ has_key(a:param, 'onto') ? '--onto ' . a:param.onto : '',
\ has_key(a:param, 'upstream') ? a:param.upstream : '',
\ ))
return giti#system_with_specifics({
\ 'command' : printf('rebase %s %s',
\ has_key(a:param, 'onto')
\ ? '--onto ' . a:param.onto
\ : '',
\ has_key(a:param, 'upstream')
\ ? a:param.upstream
\ : ''
\ ),
\ 'with_confirm' : 1,
\ })
endfunction"}}}

function! giti#rebase#interactive(param)"{{{
Expand Down
18 changes: 13 additions & 5 deletions test/autoload/giti/test_rebase.vim
@@ -1,19 +1,27 @@
let s:tc = unittest#testcase#new('autoload/giti/rebase.vim')

function! s:tc.test_run()"{{{
call self.assert_equal('mocked_system',
call self.assert_equal('mocked_system_with_specifics',
\ giti#rebase#run({'upstream' : 'hoge',
\ 'onto' : 'fuga'}))
call self.assert_equal('rebase --onto fuga hoge', b:system_called_with)
call self.assert_equal({'command' : 'rebase --onto fuga hoge',
\ 'with_confirm' : 1},
\ b:system_with_specifics_called_with)

call giti#rebase#run({'upstream' : 'hoge'})
call self.assert_equal('rebase hoge', b:system_called_with)
call self.assert_equal({'command' : 'rebase hoge',
\ 'with_confirm' : 1},
\ b:system_with_specifics_called_with)

call giti#rebase#run({'onto' : 'fuga'})
call self.assert_equal('rebase --onto fuga ', b:system_called_with)
call self.assert_equal({'command' : 'rebase --onto fuga ',
\ 'with_confirm' : 1},
\ b:system_with_specifics_called_with)

call giti#rebase#run({})
call self.assert_equal('rebase ', b:system_called_with)
call self.assert_equal({'command' : 'rebase ',
\ 'with_confirm' : 1},
\ b:system_with_specifics_called_with)

call self.assert_throw('E118', 'call giti#rebase#run("", "")')
call self.assert_throw('E119', 'call giti#rebase#run()')
Expand Down

0 comments on commit 59e1f4c

Please sign in to comment.