bliss

KISS in Lua
git clone git://bvnf.space/bliss.git
Log | Files | Refs | README | LICENSE

commit 3f694094191df0918ac1397a7263905a86c27910
parent 4d36b79d28f6d8f6c00c44e09e0aebbddf9f22ab
Author: phoebos <ben@bvnf.space>
Date:   Tue, 14 Jan 2025 15:32:33 +0000

add update

Diffstat:
MREADME.md | 2+-
Mbliss/init.lua | 2+-
Abliss/update.lua | 32++++++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -14,7 +14,7 @@ An implementation of the kiss package manager in Lua. * [x] list * [ ] remove * [x] search - * [ ] update + * [x] update * [ ] upgrade * [x] version * [ ] ext diff --git a/bliss/init.lua b/bliss/init.lua @@ -7,7 +7,7 @@ local M = {} M.version = "0.0.0" -- merge these into the toplevel bliss module -local names = {"utils", "search", "list", "pkg", "download", "checksum", "build", "install"} +local names = {"utils", "search", "list", "pkg", "download", "checksum", "build", "install", "update"} for _, name in ipairs(names) do local t = require(cwd .. "." .. name) for k, v in pairs(t) do diff --git a/bliss/update.lua b/bliss/update.lua @@ -0,0 +1,32 @@ +local utils = require "bliss.utils" +local unistd = require "posix.unistd" + +local function update(env, arg) + -- args are ignored. + + utils.log("Updating repositories") + local repos = {} + + for _,repo in ipairs(env.PATH) do + local subm = utils.capture("git -C '" .. repo .. "' rev-parse --show-superproject-working-tree 2>/dev/null") + if not subm then goto continue end -- not a git repo + local repo = utils.capture("git -C '" .. (subm[1] or repo) .. "' rev-parse --show-toplevel") + if not repo then goto continue end + local repo = repo[1] + if not repos[repo] then + utils.log(repo) + unistd.chdir(repo) + -- as_user? + utils.run_quiet("git", {"pull"}) + repos[repo] = true + end + + ::continue:: + end + +end + +local M = { + update = update, +} +return M