Permalink
Browse files

Merge branch 'unite-test'

  • Loading branch information...
kmnk committed Nov 8, 2012
2 parents 7bcb3fc + b51f15e commit f646cd0bc67067f53deb8d162e282290695fdd5e
Showing with 1,985 additions and 130 deletions.
  1. +30 −10 autoload/giti.vim
  2. +2 −2 autoload/giti/checkout.vim
  3. +2 −2 autoload/giti/config.vim
  4. +1 −1 autoload/giti/diff.vim
  5. +1 −1 autoload/giti/merge.vim
  6. +2 −2 autoload/giti/pull.vim
  7. +2 −2 autoload/giti/push.vim
  8. +15 −3 autoload/unite/kinds/giti.vim
  9. +34 −27 autoload/unite/kinds/giti/branch.vim
  10. +13 −1 autoload/unite/kinds/giti/branch/new.vim
  11. +19 −7 autoload/unite/kinds/giti/config.vim
  12. +26 −14 autoload/unite/kinds/giti/log.vim
  13. +18 −6 autoload/unite/kinds/giti/remote.vim
  14. +21 −9 autoload/unite/kinds/giti/status.vim
  15. +12 −0 autoload/unite/sources/giti.vim
  16. +12 −0 autoload/unite/sources/giti/branch.vim
  17. +12 −0 autoload/unite/sources/giti/branch/new.vim
  18. +12 −0 autoload/unite/sources/giti/branch_all.vim
  19. +12 −0 autoload/unite/sources/giti/config.vim
  20. +12 −0 autoload/unite/sources/giti/log.vim
  21. +12 −0 autoload/unite/sources/giti/remote.vim
  22. +12 −0 autoload/unite/sources/giti/status.vim
  23. +7 −0 dot.vimrc.test
  24. +1 −1 test/autoload/giti/test_config.vim
  25. +1 −1 test/autoload/giti/test_merge.vim
  26. +1 −0 test/autoload/test_all.vim
  27. +0 −41 test/autoload/test_giti.vim
  28. +2 −0 test/autoload/unite/kinds/giti/branch/test_all.vim
  29. +65 −0 test/autoload/unite/kinds/giti/branch/test_new.vim
  30. +7 −0 test/autoload/unite/kinds/giti/test_all.vim
  31. +246 −0 test/autoload/unite/kinds/giti/test_branch.vim
  32. +141 −0 test/autoload/unite/kinds/giti/test_config.vim
  33. +222 −0 test/autoload/unite/kinds/giti/test_log.vim
  34. +145 −0 test/autoload/unite/kinds/giti/test_remote.vim
  35. +373 −0 test/autoload/unite/kinds/giti/test_status.vim
  36. +3 −0 test/autoload/unite/kinds/test_all.vim
  37. +28 −0 test/autoload/unite/kinds/test_giti.vim
  38. +2 −0 test/autoload/unite/sources/giti/branch/test_all.vim
  39. +49 −0 test/autoload/unite/sources/giti/branch/test_new.vim
  40. +8 −0 test/autoload/unite/sources/giti/test_all.vim
  41. +49 −0 test/autoload/unite/sources/giti/test_branch.vim
  42. +49 −0 test/autoload/unite/sources/giti/test_branch_all.vim
  43. +62 −0 test/autoload/unite/sources/giti/test_config.vim
  44. +52 −0 test/autoload/unite/sources/giti/test_log.vim
  45. +56 −0 test/autoload/unite/sources/giti/test_remote.vim
  46. +48 −0 test/autoload/unite/sources/giti/test_status.vim
  47. +3 −0 test/autoload/unite/sources/test_all.vim
  48. +48 −0 test/autoload/unite/sources/test_giti.vim
  49. +3 −0 test/autoload/unite/test_all.vim
  50. +32 −0 test/mock/autoload/unite.vim
View
@@ -24,18 +24,18 @@ endfunction"}}}
function! giti#system_with_specifics(param)"{{{
if !giti#is_git_repository()
- echo 'Not a git repository'
- echo 'Specify directory of git repository (and change current directory of this window)'
- echo 'current : ' . getcwd()
- call giti#execute(printf('lcd %s', input('change to: ', getcwd())))
+ call giti#print('Not a git repository')
+ call giti#print('Specify directory of git repository (and change current directory of this window)')
+ call giti#print('current : ' . getcwd())
+ call giti#execute(printf('lcd %s', giti#input('change to: ', getcwd())))
return giti#system_with_specifics(a:param)
endif
let a:param.command = s:trim(a:param.command)
if exists('a:param.with_confirm') && a:param.with_confirm
if !s:is_confirmed(a:param)
- echo 'canceled'
+ call giti#print('canceled')
return
endif
endif
@@ -52,7 +52,7 @@ endfunction"}}}
function! giti#dir()"{{{
if !exists('b:giti_dir')
let b:giti_dir = giti#system('rev-parse --git-dir')
- if !v:shell_error
+ if !giti#has_shell_error()
let b:giti_dir = fnamemodify(split(b:giti_dir, '\n')[0], ':p')
endif
endif
@@ -121,11 +121,31 @@ function! giti#diffthis()"{{{
diffthis
endfunction"}}}
+function! giti#print(string)"{{{
+ echo a:string
+endfunction"}}}
+
+function! giti#has_shell_error()"{{{
+ return v:shell_error ? 1 : 0
+endfunction"}}}
+
+function! giti#input(prompt, ...)"{{{
+ if a:0 <= 0
+ return input(prompt)
+ endif
+ if a:0 == 1
+ return input(prompt, a:1)
+ endif
+ if a:0 == 2
+ return input(prompt, a:1, a:2)
+ endif
+endfunction"}}}
+
" local functions {{{
function! s:handle_error(res, param)"{{{
- if v:shell_error
- echo 'error occured on executing "git ' . a:param.command . '"'
- echo a:res
+ if giti#has_shell_error()
+ call giti#print('error occured on executing "git ' . a:param.command . '"')
+ call giti#print(a:res)
return
else
return a:res
@@ -134,7 +154,7 @@ endfunction"}}}
function! s:is_confirmed(param)
let command = 'git ' . a:param.command
- return input('execute "' . command . '" ? [y/n] : ') == 'y' ? 1 : 0
+ return giti#input('execute "' . command . '" ? [y/n] : ') == 'y' ? 1 : 0
endfunction
function! s:trim(string)"{{{
@@ -21,13 +21,13 @@ endfunction"}}}
function! giti#checkout#create(param)"{{{
let name = a:param.name
- echo 'create new branch [' . name . ']'
+ call giti#print('create new branch [' . name . ']')
let start_point = ''
if exists('a:param.start_point')
let start_point = a:param.start_point
else
- let start_point = input('start-point (optional) : ')
+ let start_point = giti#input('start-point (optional) : ')
endif
return giti#system('checkout -b ' . name . ' ' . start_point)
View
@@ -102,7 +102,7 @@ function! s:get_list(param)"{{{
\ 'command' : 'config ' . location . ' -l',
\ 'ignore_error' : 1,
\ })
- if v:shell_error
+ if giti#has_shell_error()
return []
endif
return split(res, '\n')
@@ -113,7 +113,7 @@ function! s:build_config_data(param)"{{{
let splited = split(line, '=')
if len(splited) != 2
- echoerr 'invalid config line :' . line
+ throw 'invalid config line :' . line
endif
let location = exists('a:param.location') ? a:param.location
View
@@ -35,7 +35,7 @@ endfunction"}}}
function! giti#diff#view_git_diff(diff)"{{{
if !strlen(a:diff)
- echo 'no difference'
+ call giti#print('no difference')
return
endif
return giti#new_buffer({
View
@@ -11,7 +11,7 @@ set cpo&vim
function! giti#merge#run(param)"{{{
if !exists('a:param.branch_name')
- echoerr 'branch_name required'
+ throw 'branch_name required'
return
endif
View
@@ -30,8 +30,8 @@ endfunction"}}}
function! giti#pull#expressly()"{{{
let arg = {}
let arg.command = 'pull'
- let arg.repository = input("repository: ")
- let arg.refspec = input("refspec: ")
+ let arg.repository = giti#input("repository: ")
+ let arg.refspec = giti#input("refspec: ")
return s:run(arg)
endfunction"}}}
View
@@ -36,8 +36,8 @@ endfunction"}}}
function! giti#push#expressly()"{{{
let arg = {}
let arg.command = 'push'
- let arg.repository = input("repository: ")
- let arg.refspec = input("refspec: ")
+ let arg.repository = giti#input("repository: ")
+ let arg.refspec = giti#input("refspec: ")
return s:run(arg)
endfunction"}}}
@@ -56,10 +56,10 @@ function! s:add_mv_action_on_file_kind()"{{{
function! git_mv.func(candidate)
let source = a:candidate.action__path
- echo "git mv"
- echo printf('from "%s"', source)
+ call giti#print("git mv")
+ call giti#print(printf('from "%s"', source))
- let destination = input('to: ', source)
+ let destination = giti#input('to: ', source)
let is_directory = isdirectory(destination)
return giti#mv#run({
@@ -72,6 +72,18 @@ function! s:add_mv_action_on_file_kind()"{{{
endfunction"}}}
" }}}
+" context getter {{{
+function! s:get_SID()
+ return matchstr(expand('<sfile>'), '<SNR>\d\+_')
+endfunction
+let s:SID = s:get_SID()
+delfunction s:get_SID
+
+function! unite#kinds#giti#__context__()
+ return { 'sid': s:SID, 'scope': s: }
+endfunction
+"}}}
+
let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
@@ -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
- echo giti#checkout#switch(a:candidate.action__name)
+ call giti#print(giti#checkout#switch(a:candidate.action__name))
endif
endfunction"}}}
let s:kind.alias_table.switch = 'run'
@@ -49,18 +49,9 @@ function! s:kind.action_table.delete.func(candidates)"{{{
\ }
\ ')
- echo giti#branch#delete(map(copy(args), 'v:val.branch'))
+ call giti#print(giti#branch#delete(map(copy(args), 'v:val.branch')))
- if len(args) > 0 && !v:shell_error
- let result = s:delete_remote(args)
- if type(result) == type([])
- for output in result
- echo output ? output : 'some error occured'
- endfor
- else
- echo result
- endif
- endif
+ call s:handle_delete_remote(args)
endfunction"}}}
let s:kind.alias_table.rm = 'delete'
@@ -77,18 +68,9 @@ function! s:kind.action_table.delete_force.func(candidates)"{{{
\ }
\ ')
- echo giti#branch#delete_force(map(copy(args), 'v:val.branch'))
+ call giti#print(giti#branch#delete_force(map(copy(args), 'v:val.branch')))
- if len(args) > 0 && !v:shell_error
- let result = s:delete_remote(args)
- if type(result) == type([])
- for output in result
- echo output ? output : 'some error occured'
- endfor
- else
- echo result
- endif
- endif
+ call s:handle_delete_remote(args)
endfunction"}}}
let s:kind.action_table.merge = {
@@ -99,7 +81,7 @@ let s:kind.action_table.merge = {
\ 'is_listed' : 1,
\}
function! s:kind.action_table.merge.func(candidate)"{{{
- echo giti#merge#run({ 'branch_name' : a:candidate.action__name })
+ call giti#print(giti#merge#run({ 'branch_name' : a:candidate.action__name }))
endfunction"}}}
let s:kind.action_table.rebase = {
@@ -110,7 +92,7 @@ let s:kind.action_table.rebase = {
\ 'is_listed' : 1,
\}
function! s:kind.action_table.rebase.func(candidate)"{{{
- echo giti#rebase#run({ 'upstream' : a:candidate.action__name })
+ call giti#print(giti#rebase#run({ 'upstream' : a:candidate.action__name }))
endfunction"}}}
let s:kind.action_table.rebase_interactive = {
@@ -121,14 +103,14 @@ let s:kind.action_table.rebase_interactive = {
\ 'is_listed' : 1,
\}
function! s:kind.action_table.rebase_interactive.func(candidate)"{{{
- echo giti#rebase#interactive({ 'upstream' : a:candidate.action__name })
+ call giti#print(giti#rebase#interactive({ 'upstream' : a:candidate.action__name }))
endfunction"}}}
" }}}
" local functions {{{
function! s:is_deleting_remote_confirmed(params)"{{{
- return input('delete remote branches ? [y/n] : ') == 'y' ? 1 : 0
+ return giti#input('delete remote branches ? [y/n] : ') == 'y' ? 1 : 0
endfunction"}}}
function! s:get_repository(branch)"{{{
@@ -138,6 +120,19 @@ function! s:get_repository(branch)"{{{
\ })
endfunction"}}}
+function! s:handle_delete_remote(params)"{{{
+ if len(a:params) > 0 && !giti#has_shell_error()
+ let result = s:delete_remote(a:params)
+ if type(result) == type([])
+ for output in result
+ call giti#print(output ? output : 'some error occured')
+ endfor
+ else
+ call giti#print(result)
+ endif
+ endif
+endfunction"}}}
+
function! s:delete_remote(params)"{{{
if s:is_deleting_remote_confirmed(a:params)
return giti#branch#delete_remote(a:params)
@@ -147,6 +142,18 @@ function! s:delete_remote(params)"{{{
endfunction"}}}
" }}}
+" context getter {{{
+function! s:get_SID()
+ return matchstr(expand('<sfile>'), '<SNR>\d\+_')
+endfunction
+let s:SID = s:get_SID()
+delfunction s:get_SID
+
+function! unite#kinds#giti#branch#__context__()
+ return { 'sid': s:SID, 'scope': s: }
+endfunction
+"}}}
+
let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
@@ -28,7 +28,7 @@ function! s:kind.action_table.run.func(candidate)"{{{
if a:candidate.action__start_point != ''
let arg.start_point = a:candidate.action__start_point
endif
- echo giti#checkout#create(arg)
+ call giti#print(giti#checkout#create(arg))
endfunction"}}}
let s:kind.alias_table.create = 'run'
let s:kind.alias_table.new = 'run'
@@ -38,6 +38,18 @@ let s:kind.alias_table.new = 'run'
" local functions {{{
" }}}
+" context getter {{{
+function! s:get_SID()
+ return matchstr(expand('<sfile>'), '<SNR>\d\+_')
+endfunction
+let s:SID = s:get_SID()
+delfunction s:get_SID
+
+function! unite#kinds#giti#branch#new#__context__()
+ return { 'sid': s:SID, 'scope': s: }
+endfunction
+"}}}
+
let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
@@ -28,7 +28,7 @@ function! s:kind.action_table.yank_value.func(candidate)"{{{
if a:candidate.action__is_new
return s:create_new_config(a:candidate)
else
- echo 'yanked ' . a:candidate.action__key
+ call giti#print('yanked ' . a:candidate.action__key)
let @" = a:candidate.action__value
return
endif
@@ -43,9 +43,9 @@ let s:kind.action_table.write = {
\}
function! s:kind.action_table.write.func(candidate)"{{{
let location = s:get_location(a:candidate.action__location)
- echo printf('write "%s" on %s', a:candidate.action__key, location)
- echo printf('current value: %s', a:candidate.action__value)
- let value = input('new value: ', a:candidate.action__value)
+ call giti#print(printf('write "%s" on %s', a:candidate.action__key, location))
+ call giti#print(printf('current value: %s', a:candidate.action__value))
+ let value = giti#input('new value: ', a:candidate.action__value)
let res = giti#config#write({
\ 'key' : a:candidate.action__key,
\ 'value' : value,
@@ -79,9 +79,9 @@ function! s:get_location(location)"{{{
endfunction"}}}
function! s:create_new_config(candidate)"{{{
- echo 'create new config "' . a:candidate.action__key . '"'
- let location = s:get_location(input('location(default is "local") : '))
- let value = input('value : ')
+ call giti#print('create new config "' . a:candidate.action__key . '"')
+ let location = s:get_location(giti#input('location(default is "local") : '))
+ let value = giti#input('value : ')
let res = giti#config#add({
\ 'key' : a:candidate.action__key,
\ 'value' : value,
@@ -90,6 +90,18 @@ function! s:create_new_config(candidate)"{{{
endfunction"}}}
" }}}
+" context getter {{{
+function! s:get_SID()
+ return matchstr(expand('<sfile>'), '<SNR>\d\+_')
+endfunction
+let s:SID = s:get_SID()
+delfunction s:get_SID
+
+function! unite#kinds#giti#config#__context__()
+ return { 'sid': s:SID, 'scope': s: }
+endfunction
+"}}}
+
let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
Oops, something went wrong.

0 comments on commit f646cd0

Please sign in to comment.