mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-02 12:19:12 +00:00
Update gitget.lua
This commit is contained in:
parent
2d63440f5c
commit
637f9f4250
10
gitget.lua
10
gitget.lua
@ -245,8 +245,9 @@ local sPrint = function(str)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local getFromGitHub
|
local getFromGitHub
|
||||||
getFromGitHub = function(reponame, repopath, filepath, verbose)
|
getFromGitHub = function(reponame, repopath, filepath, branch, verbose)
|
||||||
local jason = http.get("https://api.github.com/repos/" .. reponame .. "/contents/" .. (repopath or ""), {
|
branch = branch or "master"
|
||||||
|
local jason = http.get("https://api.github.com/repos/" .. reponame .. "/contents/" .. (repopath or "") .. "?ref=" .. branch, {
|
||||||
["Authorization"] = token
|
["Authorization"] = token
|
||||||
})
|
})
|
||||||
if not jason then return false end
|
if not jason then return false end
|
||||||
@ -260,12 +261,13 @@ getFromGitHub = function(reponame, repopath, filepath, verbose)
|
|||||||
sPrint("'" .. fs.combine(filepath, v.name) .. "'")
|
sPrint("'" .. fs.combine(filepath, v.name) .. "'")
|
||||||
end
|
end
|
||||||
writeToFile(fs.combine(filepath, v.name), http.get(v.download_url).readAll())
|
writeToFile(fs.combine(filepath, v.name), http.get(v.download_url).readAll())
|
||||||
|
os.queueEvent("gitget_got", v.name, filepath, v.download_url)
|
||||||
elseif v.type == "dir" then
|
elseif v.type == "dir" then
|
||||||
if verbose then
|
if verbose then
|
||||||
sPrint("'" .. fs.combine(filepath,v.name) .. "'")
|
sPrint("'" .. fs.combine(filepath,v.name) .. "'")
|
||||||
end
|
end
|
||||||
fs.makeDir(fs.combine(filepath, v.name))
|
fs.makeDir(fs.combine(filepath, v.name))
|
||||||
getFromGitHub(reponame, fs.combine(repopath, v.name), fs.combine(filepath, v.name), verbose)
|
getFromGitHub(reponame, fs.combine(repopath, v.name), fs.combine(filepath, v.name), branch, verbose)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -309,7 +311,7 @@ else
|
|||||||
local oldtxt = (term.getTextColor and term.getTextColor()) or colors.white
|
local oldtxt = (term.getTextColor and term.getTextColor()) or colors.white
|
||||||
sPrint("Downloading...")
|
sPrint("Downloading...")
|
||||||
term.setTextColor(term.isColor() and colors.green or colors.lightGray)
|
term.setTextColor(term.isColor() and colors.green or colors.lightGray)
|
||||||
getFromGitHub(reponame, repopath, outpath, verbose)
|
getFromGitHub(reponame, repopath, outpath, branch, verbose)
|
||||||
term.setTextColor(oldtxt)
|
term.setTextColor(oldtxt)
|
||||||
sPrint("Downloaded to /" .. fs.combine("", outpath))
|
sPrint("Downloaded to /" .. fs.combine("", outpath))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user