Update git.lua to use headers authorization. #29
@@ -15,4 +15,5 @@
|
|||||||
## Install
|
## Install
|
||||||
```
|
```
|
||||||
pastebin run uzghlbnc
|
pastebin run uzghlbnc
|
||||||
|
reboot
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ local function run(file, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
_G._syslog = function() end
|
_G._syslog = function() end
|
||||||
_G.OPUS_BRANCH = 'develop-1.8'
|
_G.OPUS_BRANCH = 'master-1.8'
|
||||||
|
|
||||||
-- Install require shim
|
-- Install require shim
|
||||||
_G.requireInjector = run('sys/modules/opus/injector.lua')
|
_G.requireInjector = run('sys/modules/opus/injector.lua')
|
||||||
|
|||||||
@@ -3,12 +3,16 @@ local Util = require('opus.util')
|
|||||||
|
|
||||||
local TREE_URL = 'https://api.github.com/repos/%s/%s/git/trees/%s?recursive=1'
|
local TREE_URL = 'https://api.github.com/repos/%s/%s/git/trees/%s?recursive=1'
|
||||||
local FILE_URL = 'https://raw.githubusercontent.com/%s/%s/%s/%s'
|
local FILE_URL = 'https://raw.githubusercontent.com/%s/%s/%s/%s'
|
||||||
|
local TREE_HEADERS = {}
|
||||||
local git = { }
|
local git = { }
|
||||||
|
|
||||||
if _G._GIT_API_KEY then
|
if _G._GIT_API_KEY then
|
||||||
TREE_URL = TREE_URL .. '&access_token=' .. _G._GIT_API_KEY
|
TREE_HEADERS.Authorization = 'token ' .. _G._GIT_API_KEY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local fs = _G.fs
|
||||||
|
local os = _G.os
|
||||||
|
|
||||||
function git.list(repository)
|
function git.list(repository)
|
||||||
local t = Util.split(repository, '(.-)/')
|
local t = Util.split(repository, '(.-)/')
|
||||||
|
|
||||||
@@ -23,8 +27,10 @@ function git.list(repository)
|
|||||||
|
|
||||||
local function getContents()
|
local function getContents()
|
||||||
local dataUrl = string.format(TREE_URL, user, repo, branch)
|
local dataUrl = string.format(TREE_URL, user, repo, branch)
|
||||||
local contents = Util.download(dataUrl)
|
local contents, msg = Util.httpGet(dataUrl,TREE_HEADERS)
|
||||||
if contents then
|
if not contents then
|
||||||
|
error(_sformat('Failed to download %s\n%s', dataUrl, msg), 2)
|
||||||
|
else
|
||||||
return json.decode(contents)
|
return json.decode(contents)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user