mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-15 19:45:46 +08:00
Add Git mv command (#4350)
This commit is contained in:
parent
697fec62ea
commit
487f4fa543
@ -31,6 +31,8 @@ function! git#run(...) abort
|
|||||||
call git#diff#run(a:000[1:])
|
call git#diff#run(a:000[1:])
|
||||||
elseif cmd ==# 'rm'
|
elseif cmd ==# 'rm'
|
||||||
call git#rm#run(a:000[1:])
|
call git#rm#run(a:000[1:])
|
||||||
|
elseif cmd ==# 'mv'
|
||||||
|
call git#mv#run(a:000[1:])
|
||||||
elseif cmd ==# 'log'
|
elseif cmd ==# 'log'
|
||||||
call git#log#run(a:000[1:])
|
call git#log#run(a:000[1:])
|
||||||
elseif cmd ==# 'reflog'
|
elseif cmd ==# 'reflog'
|
||||||
@ -74,13 +76,15 @@ function! git#complete(ArgLead, CmdLine, CursorPos) abort
|
|||||||
return join(['add', 'push', 'status', 'commit', 'diff',
|
return join(['add', 'push', 'status', 'commit', 'diff',
|
||||||
\ 'merge', 'rebase', 'branch', 'checkout',
|
\ 'merge', 'rebase', 'branch', 'checkout',
|
||||||
\ 'fetch', 'reset', 'log', 'config', 'reflog',
|
\ 'fetch', 'reset', 'log', 'config', 'reflog',
|
||||||
\ 'blame', 'pull', 'stash', 'cherry-pick', 'rm'
|
\ 'blame', 'pull', 'stash', 'cherry-pick', 'rm', 'mv'
|
||||||
\ ],
|
\ ],
|
||||||
\ "\n")
|
\ "\n")
|
||||||
elseif str =~# '^Git\s\+add\s\+.*$'
|
elseif str =~# '^Git\s\+add\s\+.*$'
|
||||||
return git#add#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
return git#add#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
elseif str =~# '^Git\s\+rm\s\+.*$'
|
elseif str =~# '^Git\s\+rm\s\+.*$'
|
||||||
return git#rm#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
return git#rm#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
|
elseif str =~# '^Git\s\+mv\s\+.*$'
|
||||||
|
return git#mv#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
elseif str =~# '^Git\s\+push\s\+.*$'
|
elseif str =~# '^Git\s\+push\s\+.*$'
|
||||||
return git#push#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
return git#push#complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||||
elseif str =~# '^Git\s\+diff\s\+.*$'
|
elseif str =~# '^Git\s\+diff\s\+.*$'
|
||||||
|
46
bundle/git.vim/autoload/git/mv.vim
Normal file
46
bundle/git.vim/autoload/git/mv.vim
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
""
|
||||||
|
" @section git-mv, mv
|
||||||
|
" @parentsection commands
|
||||||
|
" This commands is to run `git mv` command asynchronously.
|
||||||
|
" It is to move file to the index. For example, rename current file.
|
||||||
|
" >
|
||||||
|
" :Git mv % new_file.txt
|
||||||
|
" <
|
||||||
|
|
||||||
|
let s:JOB = SpaceVim#api#import('job')
|
||||||
|
|
||||||
|
function! git#mv#run(args) abort
|
||||||
|
|
||||||
|
let args = a:args
|
||||||
|
if index(a:args, '%') !=# -1
|
||||||
|
let index = index(a:args, '%')
|
||||||
|
let args[index] = expand('%')
|
||||||
|
endif
|
||||||
|
let cmd = ['git', 'mv'] + args
|
||||||
|
call git#logger#info('git-mv cmd:' . string(cmd))
|
||||||
|
call s:JOB.start(cmd,
|
||||||
|
\ {
|
||||||
|
\ 'on_exit' : function('s:on_exit'),
|
||||||
|
\ }
|
||||||
|
\ )
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:on_exit(id, data, event) abort
|
||||||
|
call git#logger#info('git-mv exit data:' . string(a:data))
|
||||||
|
if a:data ==# 0
|
||||||
|
if exists(':GitGutter')
|
||||||
|
GitGutter
|
||||||
|
endif
|
||||||
|
echo 'done!'
|
||||||
|
else
|
||||||
|
echo 'failed!'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! git#rm#complete(ArgLead, CmdLine, CursorPos) abort
|
||||||
|
|
||||||
|
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n")
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
@ -7,8 +7,9 @@ CONTENTS *git-contents*
|
|||||||
2. Commands...................................................|git-commands|
|
2. Commands...................................................|git-commands|
|
||||||
1. git-add.....................................................|git-add|
|
1. git-add.....................................................|git-add|
|
||||||
2. git-cherry-pick.....................................|git-cherry-pick|
|
2. git-cherry-pick.....................................|git-cherry-pick|
|
||||||
3. git-rm.......................................................|git-rm|
|
3. git-mv.......................................................|git-mv|
|
||||||
4. git-stash.................................................|git-stash|
|
4. git-rm.......................................................|git-rm|
|
||||||
|
5. git-stash.................................................|git-stash|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INTRODUCTION *git-intro*
|
INTRODUCTION *git-intro*
|
||||||
@ -39,6 +40,15 @@ This command is to cherry pick commit from other branch.
|
|||||||
:Git cherry-pick <HashA> <HashB>
|
:Git cherry-pick <HashA> <HashB>
|
||||||
<
|
<
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
GIT-MV *git-mv*
|
||||||
|
|
||||||
|
This commands is to run `git mv` command asynchronously. It is to move file to
|
||||||
|
the index. For example, rename current file.
|
||||||
|
>
|
||||||
|
:Git mv % new_file.txt
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
GIT-RM *git-rm*
|
GIT-RM *git-rm*
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user