Permalink
Browse files

Can select files on commiting amend

  • Loading branch information...
1 parent cda9e85 commit b0ffd7cd2c25a59d0b99e81710a1ac372d8872f4 @kmnk committed Feb 13, 2013
@@ -17,8 +17,8 @@ function! giti#commit#dry_run(files)"{{{
return s:run('commit --dry-run', a:files)
endfunction"}}}
-function! giti#commit#amend()"{{{
- return s:run('commit --amend', [])
+function! giti#commit#amend(files)"{{{
+ return s:run('commit --amend', a:files)
endfunction"}}}
" local functions {{{
@@ -73,7 +73,13 @@ let s:kind.action_table.amend = {
\ 'is_selectable' : 1,
\}
function! s:kind.action_table.amend.func(candidates)"{{{
- return giti#commit#amend()
+ let files = []
+ for candidate in a:candidates
+ for path in candidate.action__paths
+ call add(files, path)
+ endfor
+ endfor
+ return giti#commit#amend(files)
endfunction"}}}
let s:kind.action_table.checkout = {
@@ -34,15 +34,16 @@ endfunction"}}}
function! s:tc.test_amend()"{{{
- call giti#commit#amend()
+ call giti#commit#amend(['hoge', 'fuga'])
call self.assert_equal(
\ b:system_with_specifics_called_with,
\ {
-\ 'command' : 'commit --amend -- ',
+\ 'command' : 'commit --amend -- hoge fuga',
\ 'ignore_error' : 1,
\ }
\ )
- call self.assert_throw('E118', 'call giti#commit#amend("")')
+ call self.assert_throw('E118', 'call giti#commit#amend("", "")')
+ call self.assert_throw('E119', 'call giti#commit#amend()')
endfunction"}}}
unlet s:tc
@@ -126,7 +126,8 @@ function! s:tc.test_kind_action_commit()"{{{
endfunction"}}}
function! s:tc.setup_kind_action_amend()"{{{
- function! giti#commit#amend()"{{{
+ function! giti#commit#amend(param)"{{{
+ let b:commit_amend_called_with = a:param
return 'mocked giti#commit#amend'
endfunction"}}}
endfunction"}}}
@@ -144,6 +145,10 @@ function! s:tc.test_kind_action_amend()"{{{
let candidates = [{ 'action__paths' : [ 'hoge', 'fuga' ] }]
call self.assert_equal('mocked giti#commit#amend', amend.func(candidates))
+ call self.assert_equal([
+\ candidates[0].action__paths[0],
+\ candidates[0].action__paths[1]
+\ ], b:commit_amend_called_with)
endfunction"}}}
function! s:tc.setup_kind_action_checkout()"{{{

0 comments on commit b0ffd7c

Please sign in to comment.