mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:10:04 +08:00
Add command to manage pull request
* Add command to create pull request * Update * Update * Update
This commit is contained in:
parent
e651113cb4
commit
73a8465bce
41
.SpaceVim.d/autoload/SpaceVim/dev/pull.vim
Normal file
41
.SpaceVim.d/autoload/SpaceVim/dev/pull.vim
Normal file
@ -0,0 +1,41 @@
|
||||
function! SpaceVim#dev#pull#create(branch)
|
||||
let title = input('title:')
|
||||
call inputsave()
|
||||
let username = input('github username:')
|
||||
let password = input('github password:')
|
||||
call inputrestore()
|
||||
let pull = {
|
||||
\ 'title' : title,
|
||||
\ 'head' : 'wsdjeg:' . a:branch,
|
||||
\ 'base' : 'master'
|
||||
\ }
|
||||
let respons = github#api#pulls#create('SpaceVim', 'SpaceVim', username, password, pull)
|
||||
normal! :
|
||||
if !empty(respons) && get(respons, 'number', 0) > 0
|
||||
echon 'Pull request #' . respons.number . ' has been created!'
|
||||
elseif !empty(respons)
|
||||
let msg = get(respons, 'message', '')
|
||||
echon 'Failed to create pull request ' . respons.number . ':' . msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#dev#pull#merge(id) abort
|
||||
let commit_title = input('commit title:')
|
||||
call inputsave()
|
||||
let username = input('github username:')
|
||||
let password = input('github password:')
|
||||
call inputrestore()
|
||||
let commit = {
|
||||
\ 'commit_title' : commit_title,
|
||||
\ 'merge_method' : 'squash'
|
||||
\ }
|
||||
let respons = github#api#pulls#Merge('SpaceVim', 'SpaceVim', a:id, commit, username, password)
|
||||
normal! :
|
||||
if !empty(respons) && has_key(respons, 'sha')
|
||||
echon 'Pull request #' . a:id . ' has been merged!'
|
||||
elseif !empty(respons)
|
||||
let msg = get(respons, 'message', '')
|
||||
echon 'Failed to merge pull request ' . a:id . ':' . msg
|
||||
endif
|
||||
endfunction
|
@ -30,4 +30,6 @@ endfunction
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('vader', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#a#set_config_name('.projections.json')
|
||||
command! -nargs=1 IssueEdit call SpaceVim#dev#issuemanager#edit(<f-args>)
|
||||
command! -nargs=1 PullCreate call SpaceVim#dev#pull#create(<f-args>)
|
||||
command! -nargs=1 PullMerge call SpaceVim#dev#pull#merge(<f-args>)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user