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

fix(github api): fix authentication

This commit is contained in:
wsdjeg 2023-03-31 13:32:08 +08:00 committed by GitHub
parent d518040658
commit b30894369c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 3 deletions

View File

@ -366,6 +366,27 @@ EOT
rm -rf detach/$1
exit 0
;;
github.vim)
git clone https://github.com/wsdjeg/GitHub.vim.git detach/$1
cd detach/$1
_checkdir plugin/
_checkdir autoload/
_detact LICENSE
_detact_bundle github.vim autoload/github.vim
_detact_bundle github.vim plugin/github.vim
_default_readme "GitHub.vim" "GitHub API support for neovim/vim[wip]"
_checkdir doc/
_detact_bundle github doc/github.txt
git add .
git config user.email "wsdjeg@qq.com"
git config user.name "SpaceVimBot"
git commit -m "Auto Update based on https://github.com/SpaceVim/SpaceVim/commit/${GITHUB_SHA}"
git remote add wsdjeg_github_vim https://SpaceVimBot:${BOTSECRET}@github.com/wsdjeg/GitHub.vim.git
git push wsdjeg_github_vim master
cd -
rm -rf detach/$1
exit 0
;;
spacevim-theme)
exit 0
esac

View File

@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
detachPlugin: ["flygrep", "dein-ui", "vim-todo", "iedit", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim"]
detachPlugin: ["flygrep", "dein-ui", "vim-todo", "iedit", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "github.vim"]
runs-on: ubuntu-latest
steps:
- name: Checkout

View File

@ -0,0 +1,7 @@
function! github#api#authorize() abort
if !empty(g:githubapi_token)
return ['--header', "Authorization: Bearer " . g:githubapi_token]
else
return []
endif
endfunction

View File

@ -107,11 +107,18 @@ endfunction
" <
" Github API : POST /repos/:owner/:repo/issues
function! github#api#issues#Create(owner,repo,user,password,issue) abort
if empty(a:password) || empty(a:user)
return github#api#util#Get('repos/' . a:owner . '/' . a:repo . '/issues',
\ ['-X', 'POST', '-d', json_encode(a:issue),
\ '-u', a:user . ':' . a:password])
\ ['-X', 'POST', '-d', json_encode(a:issue)
\ ] + github#api#authorize())
else
return github#api#util#Get('repos/' . a:owner . '/' . a:repo . '/issues',
\ ['-X', 'POST', '-d', json_encode(a:issue),
\ '-u', a:user . ':' . a:password])
endif
endfunction
""
" Edit an issue
" PATCH /repos/:owner/:repo/issues/:number

View File

@ -13,6 +13,8 @@ let g:githubapi_root_url = 'https://api.github.com/'
""
" set githubapi verbose when run shell command. By default it is 0.
let g:githubapi_verbose = get(g:, 'githubapi_verbose', 0)
let g:githubapi_token = ''
""
" Specific the path for curl, by default it is 'curl', in windows you can use
" >