Skip to content

Commit 6979188

Browse files
committed
Add force push mapping
1 parent 2feeb92 commit 6979188

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ let g:vim_project_config.git_local_changes_mappings = {
396396
\'pull': 'u',
397397
\'push': 'p',
398398
\'pull_and_push': 'P',
399+
\'force_push': 'F',
399400
\}
400401
```
401402

autoload/project.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function! s:Prepare()
143143
\'pull': 'u',
144144
\'push': 'p',
145145
\'pull_and_push': 'P',
146+
\'force_push': 'F',
146147
\'shelf': 's',
147148
\'unshelf': 'S',
148149
\}

autoload/project/git.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ function! s:SetupChangelistBuffer()
15191519
call s:AddMapping(mappings.pull, '<SID>TryPull()')
15201520
call s:AddMapping(mappings.push, '<SID>TryPush()')
15211521
call s:AddMapping(mappings.pull_and_push, '<SID>TryPullThenPush()')
1522+
call s:AddMapping(mappings.force_push, '<SID>TryPush(1)')
15221523
call s:AddMapping(mappings.new_changelist, '<SID>NewChangelistFolder()')
15231524
call s:AddMapping(mappings.move_to_changelist, '<SID>MoveToFolder()')
15241525
call s:AddVisualMapping(mappings.move_to_changelist, '<SID>MoveToFolder()')
@@ -1686,9 +1687,9 @@ function! s:TryCommit()
16861687
nnoremap<buffer><silent> p :call <SID>TryPullThenPush()<cr>
16871688
endfunction
16881689

1689-
function! s:TryPush()
1690-
call project#Info('Pushing...')
1691-
let cmd = 'git push'
1690+
function! s:TryPush(force=0)
1691+
call project#Info(a:force ? 'Force pushing...' : 'Pushing...')
1692+
let cmd = a:force ? 'git push -f' : 'git push'
16921693
let result = project#RunShellCmd(cmd)
16931694
if v:shell_error
16941695
return

0 commit comments

Comments
 (0)