self update
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
local GIT_TOKEN = "" -- Leave empty for public repos, or add "your-token-here"
|
||||
-- Leave empty for public repos, or add "your-token-here"
|
||||
local GIT_TOKEN = ""
|
||||
-- Update config
|
||||
local GIT_URL = "https://git.ejebring.com/eejebring/CC-tweaked-Gitea-Client/raw/branch/main/git.lua"
|
||||
local GIT_FILE = "git.lua"
|
||||
|
||||
-- Parse a Gitea URL like: https://gitea.example.com/owner/repo or /owner/repo/branch/filename
|
||||
local function parseGiteaURL(url)
|
||||
@@ -97,13 +101,22 @@ end
|
||||
local args = { ... }
|
||||
if args[1] == "clone" and args[2] then
|
||||
cloneRepo(args[2])
|
||||
elseif args[1] == "update" then
|
||||
local req = http.get(GIT_URL)
|
||||
if not req then error("Failed to download update.") end
|
||||
local code = req.readAll()
|
||||
if not code then error("Recived empty response from server.") end
|
||||
local file = fs.open(GIT_FILE, "w+")
|
||||
if not file then error("Could not overwite " .. GIT_FILE) end
|
||||
file.write(code)
|
||||
else
|
||||
print("Usage:")
|
||||
print(" git pull <full-gitea-url>")
|
||||
print(" git update")
|
||||
print(" git clone <full-gitea-url>")
|
||||
print("")
|
||||
print("Examples:")
|
||||
print(' git pull "https://gitea.example.com/user/myrepo"')
|
||||
print(' git pull "https://gitea.example.com/user/myrepo/tree/main/path/to/file.lua"')
|
||||
print(' git clone "https://gitea.example.com/user/myrepo"')
|
||||
print(' git clone "https://gitea.example.com/user/myrepo/tree/main/path/to/file.lua"')
|
||||
print("")
|
||||
print("Set GIT_TOKEN variable above for private repos.")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user