Add support for base branch in vim PR commands
parent
1c76a83d48
commit
9772330d5c
|
@ -18,30 +18,34 @@ endfunction
|
||||||
" Tested only with github.com
|
" Tested only with github.com
|
||||||
" Works regardless of ssh or https for origin config
|
" Works regardless of ssh or https for origin config
|
||||||
" Hardcoded to use 'origin' remote
|
" Hardcoded to use 'origin' remote
|
||||||
function! s:GetPrUrl()
|
function! s:GetPrUrl(...)
|
||||||
let origin_url = fugitive#RemoteUrl('origin')
|
let origin_url = fugitive#RemoteUrl('origin')
|
||||||
let origin_url = substitute(l:origin_url, '\.git$', '', '')
|
let origin_url = substitute(l:origin_url, '\.git$', '', '')
|
||||||
let origin_url = substitute(l:origin_url, ':', '/', '')
|
let origin_url = substitute(l:origin_url, ':', '/', '')
|
||||||
let origin_url = substitute(l:origin_url, 'git@', 'https://', '')
|
let origin_url = substitute(l:origin_url, 'git@', 'https://', '')
|
||||||
let pr_url = l:origin_url . '/compare/' . FugitiveHead() . '?expand=1'
|
if a:0 == 0
|
||||||
|
let pr_url = l:origin_url . '/compare/' . FugitiveHead() . '?expand=1'
|
||||||
|
else
|
||||||
|
let pr_url = l:origin_url . '/compare/' . a:1 . '...' . FugitiveHead() . '?expand=1'
|
||||||
|
endif
|
||||||
return l:pr_url
|
return l:pr_url
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Prints current branches PR url (not saved to :messages)
|
" Prints current branches PR url (not saved to :messages)
|
||||||
" Makes it easy to use terminal for opening url on click
|
" Makes it easy to use terminal for opening url on click
|
||||||
function! s:PrintPrUrl()
|
function! s:PrintPrUrl(...)
|
||||||
echo s:GetPrUrl()
|
echo call('s:GetPrUrl', a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Copies current branches PR url to system clipboard
|
" Copies current branches PR url to system clipboard
|
||||||
function! s:CopyPrUrl()
|
function! s:CopyPrUrl(...)
|
||||||
let @+ = s:GetPrUrl()
|
let @+ = call('s:GetPrUrl', a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Opens current banches PR url in default browser
|
" Opens current banches PR url in default browser
|
||||||
" Utilizes netrw browse, meaning it should behave same as netrw
|
" Utilizes netrw browse, meaning it should behave same as netrw
|
||||||
function! s:OpenNewPr()
|
function! s:OpenNewPr(...)
|
||||||
call netrw#BrowseX(s:GetPrUrl(), 0)
|
call netrw#BrowseX(call('s:GetPrUrl', a:000), 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Creates new branch and checks out to it
|
" Creates new branch and checks out to it
|
||||||
|
@ -57,10 +61,10 @@ endfunction
|
||||||
|
|
||||||
command! -nargs=0 Ggpush :call s:PushOrigin()
|
command! -nargs=0 Ggpush :call s:PushOrigin()
|
||||||
command! -nargs=0 Ggpull :call s:PullOrigin()
|
command! -nargs=0 Ggpull :call s:PullOrigin()
|
||||||
command! -nargs=0 Gpropen :call s:OpenNewPr()
|
command! -nargs=? Gpropen :call s:OpenNewPr(<f-args>)
|
||||||
command! -nargs=0 Gpr Gpropen
|
command! -nargs=? Gpr Gpropen <args>
|
||||||
command! -nargs=0 Gprprint :call s:PrintPrUrl()
|
command! -nargs=? Gprprint :call s:PrintPrUrl(<f-args>)
|
||||||
command! -nargs=0 Gprcopy :call s:CopyPrUrl()
|
command! -nargs=? Gprcopy :call s:CopyPrUrl(<f-args>)
|
||||||
command! -nargs=1 Gcbranch :call s:CreateBranch(<f-args>)
|
command! -nargs=1 Gcbranch :call s:CreateBranch(<f-args>)
|
||||||
command! -nargs=0 Gcmaster :call s:CheckoutBranch('main')
|
command! -nargs=0 Gcmaster :call s:CheckoutBranch('main')
|
||||||
command! -nargs=0 Gcm Gcmaster
|
command! -nargs=0 Gcm Gcmaster
|
||||||
|
|
Loading…
Reference in New Issue