Permalink
Browse files

Separate removing remote action on branch kind

  • Loading branch information...
1 parent e127582 commit 7f10dbdabf370d26514bdc493a4508c4b6b41f68 @kmnk committed May 9, 2013
Showing with 122 additions and 5 deletions.
  1. +34 −2 autoload/unite/kinds/giti/branch.vim
  2. +88 −3 test/autoload/unite/kinds/giti/test_branch.vim
@@ -50,8 +50,6 @@ function! s:kind.action_table.delete.func(candidates)"{{{
\ ')
call giti#print(giti#branch#delete(map(copy(args), 'v:val.branch')))
-
- call s:handle_delete_remote(args)
endfunction"}}}
let s:kind.alias_table.rm = 'delete'
@@ -66,6 +64,40 @@ function! s:kind.action_table.delete_force.func(candidates)"{{{
\ "branch" : v:val.action__name,
\ "repository" : s:get_repository(v:val.action__name),
\ }
+\ ')
+
+ call giti#print(giti#branch#delete_force(map(copy(args), 'v:val.branch')))
+endfunction"}}}
+
+let s:kind.action_table.delete_remote = {
+\ 'description' : 'delete this branch and remote',
+\ 'is_selectable' : 1,
+\ 'is_quit' : 1,
+\}
+function! s:kind.action_table.delete_remote.func(candidates)"{{{
+ let args = map(copy(a:candidates), '
+\ {
+\ "branch" : v:val.action__name,
+\ "repository" : s:get_repository(v:val.action__name),
+\ }
+\ ')
+
+ call giti#print(giti#branch#delete(map(copy(args), 'v:val.branch')))
+
+ call s:handle_delete_remote(args)
+endfunction"}}}
+
+let s:kind.action_table.delete_remote_force = {
+\ 'description' : 'delete force this branch and remote',
+\ 'is_selectable' : 1,
+\ 'is_quit' : 1,
+\}
+function! s:kind.action_table.delete_remote_force.func(candidates)"{{{
+ let args = map(copy(a:candidates), '
+\ {
+\ "branch" : v:val.action__name,
+\ "repository" : s:get_repository(v:val.action__name),
+\ }
\ ')
call giti#print(giti#branch#delete_force(map(copy(args), 'v:val.branch')))
@@ -75,6 +75,7 @@ function! s:tc.setup_kind_action_delete()"{{{
return 'mocked giti#config#read'
endfunction"}}}
endfunction"}}}
+
function! s:tc.teardown_kind_action_delete()"{{{
let paths = split(globpath(&rtp, 'autoload/giti/branch.vim'), '\n')
execute 'source ' . paths[0]
@@ -96,9 +97,6 @@ function! s:tc.test_kind_action_delete()"{{{
call self.assert_equal(delete.func(candidates), 'mocked giti#branch#delete')
call self.assert_equal(b:branch_delete_called_with,
\ [candidates[0].action__name])
- call self.assert_equal(b:branch_delete_remote_called_with,
-\ [{'repository' : 'mocked giti#config#read',
-\ 'branch' : candidates[0].action__name}])
endfunction"}}}
function! s:tc.setup_kind_action_delete_force()"{{{
@@ -140,6 +138,93 @@ function! s:tc.test_kind_action_delete_force()"{{{
\ }]
call self.assert_equal('mocked giti#branch#delete_force', delete_force.func(candidates))
call self.assert_equal(b:branch_delete_called_with,
+\ [candidates[0].action__name])
+endfunction"}}}
+
+function! s:tc.setup_kind_action_delete_remote()"{{{
+ function! giti#has_shell_error()"{{{
+ return 0
+ endfunction"}}}
+ function! giti#input(prompt, ...)"{{{
+ return 'y'
+ endfunction"}}}
+ function! giti#branch#delete(branches)"{{{
+ let b:branch_delete_called_with = a:branches
+ return 'mocked giti#branch#delete'
+ endfunction"}}}
+ function! giti#branch#delete_remote(branches)"{{{
+ let b:branch_delete_remote_called_with = a:branches
+ return 'mocked giti#branch#delete_remote'
+ endfunction"}}}
+ function! giti#config#read(param)"{{{
+ return 'mocked giti#config#read'
+ endfunction"}}}
+endfunction"}}}
+function! s:tc.teardown_kind_action_delete_remote()"{{{
+ let paths = split(globpath(&rtp, 'autoload/giti/branch.vim'), '\n')
+ execute 'source ' . paths[0]
+ let paths = split(globpath(&rtp, 'autoload/giti/config.vim'), '\n')
+ execute 'source ' . paths[0]
+endfunction"}}}
+function! s:tc.test_kind_action_delete_remote()"{{{
+ let kind = self.get('s:kind')
+ let delete_remote = kind.action_table.delete_remote
+ call self.assert_equal(type({}), type(delete_remote))
+ call self.assert_equal(type(''), type(delete_remote.description))
+ call self.assert_equal(delete_remote.is_selectable, 1)
+ call self.assert_equal(delete_remote.is_quit, 1)
+ call self.assert_equal(type(function('tr')), type(delete_remote.func))
+
+ let candidates = [{
+\ 'action__name' : 'hoge',
+\ }]
+ call self.assert_equal(delete_remote.func(candidates), 'mocked giti#branch#delete')
+ call self.assert_equal(b:branch_delete_called_with,
+\ [candidates[0].action__name])
+ call self.assert_equal(b:branch_delete_remote_called_with,
+\ [{'repository' : 'mocked giti#config#read',
+\ 'branch' : candidates[0].action__name}])
+endfunction"}}}
+
+function! s:tc.setup_kind_action_delete_remote_force()"{{{
+ function! giti#has_shell_error()"{{{
+ return 0
+ endfunction"}}}
+ function! giti#input(prompt, ...)"{{{
+ return 'y'
+ endfunction"}}}
+ function! giti#branch#delete_force(branches)"{{{
+ let b:branch_delete_called_with = a:branches
+ return 'mocked giti#branch#delete_force'
+ endfunction"}}}
+ function! giti#branch#delete_remote(branches)"{{{
+ let b:branch_delete_remote_called_with = a:branches
+ return 'mocked giti#branch#delete_remote'
+ endfunction"}}}
+ function! giti#config#read(param)"{{{
+ return 'mocked giti#config#read'
+ endfunction"}}}
+endfunction"}}}
+function! s:tc.teardown_kind_action_delete_remote_force()"{{{
+ let paths = split(globpath(&rtp, 'autoload/giti/branch.vim'), '\n')
+ execute 'source ' . paths[0]
+ let paths = split(globpath(&rtp, 'autoload/giti/config.vim'), '\n')
+ execute 'source ' . paths[0]
+endfunction"}}}
+function! s:tc.test_kind_action_delete_remote_force()"{{{
+ let kind = self.get('s:kind')
+ let delete_remote_force = kind.action_table.delete_remote_force
+ call self.assert_equal(type({}), type(delete_remote_force))
+ call self.assert_equal(type(''), type(delete_remote_force.description))
+ call self.assert_equal(delete_remote_force.is_selectable, 1)
+ call self.assert_equal(delete_remote_force.is_quit, 1)
+ call self.assert_equal(type(function('tr')), type(delete_remote_force.func))
+
+ let candidates = [{
+\ 'action__name' : 'hoge',
+\ }]
+ call self.assert_equal('mocked giti#branch#delete_force', delete_remote_force.func(candidates))
+ call self.assert_equal(b:branch_delete_called_with,
\ [candidates[0].action__name])
call self.assert_equal(b:branch_delete_remote_called_with,
\ [{'repository' : 'mocked giti#config#read',

0 comments on commit 7f10dbd

Please sign in to comment.