1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:50:06 +08:00

fix(gitcommit): fix gitcommit plugin

This commit is contained in:
wsdjeg 2022-10-27 17:55:42 +08:00
parent 591f725e18
commit a6c5d56311

View File

@ -131,7 +131,7 @@ endfunction
function! s:current_repo() abort
if executable('git')
let repo_home = fnamemodify(s:findDirInParent('.git', expand('%:p')), ':p:h:h')
let repo_home = s:find_repo_home(expand('%:p'))
if repo_home !=# '' || !isdirectory(repo_home)
let remotes = filter(systemlist('git -C '. repo_home. ' remote -v'),"match(v:val,'^origin') >= 0 && match(v:val,'fetch') > 0")
if len(remotes) > 0
@ -149,10 +149,17 @@ function! s:current_repo() abort
endif
endif
endfunction
fu! s:findDirInParent(what, where) abort " {{{2
fu! s:find_repo_home(path) abort " {{{2
if filereadable(a:path)
let where = fnamemodify(a:path, ':p:h')
elseif isdirectory(a:path)
let where = a:path
else
let where = getcwd()
endif
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let dir = finddir(a:what, escape(a:where, ' ') . ';')
let dir = finddir('.git', escape(where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return dir
endf " }}}2
@ -177,3 +184,8 @@ function! s:list_callback(user, repo, data) abort
endif
endfor
endfunction
function! Test(str) abort
exe a:str
endfunction