1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:20:05 +08:00

Add command to manage pull request

* Add command to create pull request

* Update

* Update

* Update
This commit is contained in:
Wang Shidong 2019-09-26 01:32:34 +08:00 committed by GitHub
parent e651113cb4
commit 73a8465bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

View 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

View File

@ -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>)