From 035fb45cf671a491f75d53b15c3b93a363e2e9dd Mon Sep 17 00:00:00 2001 From: eejebring Date: Fri, 21 Aug 2026 21:59:33 +0200 Subject: [PATCH] self update --- git.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/git.lua b/git.lua index d3f8860..d1ecd33 100644 --- a/git.lua +++ b/git.lua @@ -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 ") + print(" git update") + print(" git clone ") 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