From 344223afd55a93cea65501d223886c648ee9c054 Mon Sep 17 00:00:00 2001 From: Squibid Date: Sat, 29 Apr 2023 12:19:13 -0400 Subject: notifiy was in the wrong place --- lua/dep.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index 386e739..b4bce62 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -638,9 +638,7 @@ local function print_list(cb) line = line + 1 end - vim.notify(string.format("Installed packages (%s):", #packages), 'info', { - title = 'Dep', - }) + print(string.format("Installed packages (%s):", #packages)) indent = 1 local loaded = {} -- cgit v1.2.1 From 5b7b7f610f515e55c72a86bc8f49855652c0f339 Mon Sep 17 00:00:00 2001 From: Squibid Date: Sun, 30 Apr 2023 19:49:01 -0400 Subject: pin the correct repo to the top of the plugin list --- lua/dep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index b4bce62..dccd17b 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -849,7 +849,7 @@ return setmetatable({ packages = {} bench("load", function() - root = register("chiyadev/dep") + root = register("squibid/dep") register_recursive(config) sort_dependencies() ensure_acyclic() -- cgit v1.2.1 From 3d20ae8d2ac131aa2e2d2064c91ae31c800d8ea9 Mon Sep 17 00:00:00 2001 From: Squibid Date: Sun, 30 Apr 2023 19:49:01 -0400 Subject: pin the correct repo to the top of the plugin list --- lua/dep.lua | 27 ++++++--------------------- lua/dep/package.lua | 15 --------------- 2 files changed, 6 insertions(+), 36 deletions(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index dccd17b..20be24f 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -127,27 +127,6 @@ local function register_recursive(list, overrides) error(string.format("%s (spec=%s)", err, vim.inspect(list[i]))) end end - - if list.modules then - for i = 1, #list.modules do - local name, module = "", list.modules[i] - - if type(module) == "string" then - if list.modules.prefix then - module = list.modules.prefix .. module - end - - name, module = module, require(module) - end - - name = module.name or name - - local ok, err = pcall(register_recursive, module, overrides) - if not ok then - error(string.format("%s <- %s", err, name)) - end - end - end end local function sort_dependencies() @@ -851,6 +830,12 @@ return setmetatable({ bench("load", function() root = register("squibid/dep") register_recursive(config) + if config["load"] and type(config["load"]) == "function" then + local ok, ret = pcall(config["load"]()) + if ok and type(ret) == "table" then + register_recursive(ok) + end + end sort_dependencies() ensure_acyclic() end) diff --git a/lua/dep/package.lua b/lua/dep/package.lua index 513df8d..e76238d 100644 --- a/lua/dep/package.lua +++ b/lua/dep/package.lua @@ -168,7 +168,6 @@ local PackageStore = setmetatable({ assert(type(specs) == "table", "package list must be a table") assert(specs.pin == nil or type(specs.pin) == "boolean", "package list pin must be a boolean") assert(specs.disable == nil or type(specs.disable) == "boolean", "package list disable must be a boolean") - assert(specs.modules == nil or type(specs.modules) == "table", "package list module list must be a table") scope = scope or {} scope = { @@ -181,20 +180,6 @@ local PackageStore = setmetatable({ for i = 1, #specs do self:add_spec(specs[i], scope) end - - -- recursively add referenced spec list modules - if specs.modules then - local prefix = specs.modules.prefix or "" - for i = 1, #specs.modules do - local name = specs.modules[i] - assert(type(name) == "string", "package list inner module name must be a string") - name = prefix .. name - - local module = require(name) - assert(type(module) == "table", "package list inner module did not return a spec list table") - self:add_specs(module, scope) - end - end end, --- Ensures there are no circular dependencies in this package store. -- cgit v1.2.1 From d141c762c19d7e216b8e9953874f957b6b70775e Mon Sep 17 00:00:00 2001 From: Squibid Date: Thu, 25 Jul 2024 10:27:12 -0400 Subject: whoops --- lua/dep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index 20be24f..0e25819 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -833,7 +833,7 @@ return setmetatable({ if config["load"] and type(config["load"]) == "function" then local ok, ret = pcall(config["load"]()) if ok and type(ret) == "table" then - register_recursive(ok) + register_recursive(ret) end end sort_dependencies() -- cgit v1.2.1 From d7a08ca8205817589e90050ec20ea06591035526 Mon Sep 17 00:00:00 2001 From: Squibid Date: Thu, 25 Jul 2024 10:36:27 -0400 Subject: actually fix it this time --- lua/dep.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index 0e25819..c6deb9f 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -829,13 +829,15 @@ return setmetatable({ bench("load", function() root = register("squibid/dep") - register_recursive(config) if config["load"] and type(config["load"]) == "function" then - local ok, ret = pcall(config["load"]()) + local ok, ret = pcall(config["load"]) if ok and type(ret) == "table" then register_recursive(ret) + else + logger:log("error", ret) end end + register_recursive(config) sort_dependencies() ensure_acyclic() end) -- cgit v1.2.1 From 30e7e057718973c86e3dc811c21000ce9a5c2050 Mon Sep 17 00:00:00 2001 From: Squibid Date: Thu, 25 Jul 2024 20:01:23 -0400 Subject: make sure the load function is called on dep reloading --- lua/dep.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index c6deb9f..378ef82 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -11,7 +11,7 @@ local logger = require("dep.log").global local proc = require("dep.proc") local initialized, perf, config_path, base_dir -local packages, root +local packages, root, load local function bench(name, code, ...) local start = os.clock() @@ -396,6 +396,16 @@ local function reload() end local function reload_all() + -- recall the load function + if load and type(load) == "function" then + local ok, ret = pcall(load) + if ok and type(ret) == "table" then + register_recursive(ret) + else + logger:log("error", ret) + end + end + for i = 1, #packages do local package = packages[i] package.loaded, package.subtree_loaded = false, false @@ -832,6 +842,7 @@ return setmetatable({ if config["load"] and type(config["load"]) == "function" then local ok, ret = pcall(config["load"]) if ok and type(ret) == "table" then + load = config["load"] register_recursive(ret) else logger:log("error", ret) -- cgit v1.2.1 From 25372aea36cef2a094b1a0d8f83e0199734944f6 Mon Sep 17 00:00:00 2001 From: Squibid Date: Tue, 19 Nov 2024 12:36:55 -0600 Subject: add ability to specifiy commit ref --- lua/dep.lua | 28 +++++++++++++++++++++++----- lua/dep/proc.lua | 10 ++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index 378ef82..911ceca 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -78,6 +78,7 @@ local function register(spec, overrides) package.url = spec.url or package.url or ("https://github.com/" .. id .. ".git") package.branch = spec.branch or package.branch package.dir = base_dir .. package.name + package.commit = spec.commit package.pin = overrides.pin or spec.pin or package.pin package.enabled = not overrides.disable and not spec.disable and package.enabled @@ -493,7 +494,7 @@ local function sync(package, cb) log_err(before) cb(err) else - proc.git_fetch(package.dir, "origin", package.branch or "HEAD", function(err, message) + local function continue(err, message) if err then log_err(message) cb(err) @@ -519,7 +520,12 @@ local function sync(package, cb) end end) end - end) + end + if package.commit then + proc.git_checkout(package.dir, package.branch, package.commit, continue) + else + proc.git_fetch(package.dir, "origin", package.branch or "HEAD", continue) + end end end) else @@ -527,9 +533,21 @@ local function sync(package, cb) if err then logger:log("error", string.format("failed to install %s; reason: %s", package.id, message)) else - package.exists = true - mark_reconfigure(package) - logger:log("install", string.format("installed %s", package.id)) + if package.commit then + proc.git_checkout(package.dir, package.branch, package.commit, function(err, message) + if err then + logger:log("error", string.format("failed to checkout %s; reason: %s", package.id, message)) + else + package.exists = true + mark_reconfigure(package) + logger:log("install", string.format("installed %s", package.id)) + end + end) + else + package.exists = true + mark_reconfigure(package) + logger:log("install", string.format("installed %s", package.id)) + end end cb(err) diff --git a/lua/dep/proc.lua b/lua/dep/proc.lua index 4b95baa..3355228 100644 --- a/lua/dep/proc.lua +++ b/lua/dep/proc.lua @@ -61,4 +61,14 @@ function proc.git_reset(dir, treeish, cb) proc.exec("git", args, dir, git_env, cb) end +function proc.git_checkout(dir, branch, commit, cb) + local args = { "fetch", "--unshallow", "origin", branch } + proc.exec("git", args, dir, git_env, function(err, message) + cb(err, message) + + args = { "checkout", commit } + proc.exec("git", args, dir, git_env, cb) + end) +end + return proc -- cgit v1.2.1 From 6259250120315534d31f28ffd03d36f1cdb30f7b Mon Sep 17 00:00:00 2001 From: Squibid Date: Tue, 19 Nov 2024 12:41:54 -0600 Subject: fix: --unshallow errors if the repo is already unshallow instead we use --depth=2147483647 because as noted by the docs... The special depth 2147483647 (or 0x7fffffff, the largest positive number a signed 32-bit integer can contain) means infinite depth. https://git-scm.com/docs/shallow --- lua/dep/proc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/dep/proc.lua b/lua/dep/proc.lua index 3355228..cf3aa9c 100644 --- a/lua/dep/proc.lua +++ b/lua/dep/proc.lua @@ -62,7 +62,7 @@ function proc.git_reset(dir, treeish, cb) end function proc.git_checkout(dir, branch, commit, cb) - local args = { "fetch", "--unshallow", "origin", branch } + local args = { "fetch", "--depth=2147483647", "origin", branch } proc.exec("git", args, dir, git_env, function(err, message) cb(err, message) -- cgit v1.2.1 From 443a091e3e2b0c4fc0fdcaf00d878b1edc86ce91 Mon Sep 17 00:00:00 2001 From: Squibid Date: Tue, 19 Nov 2024 12:53:06 -0600 Subject: fix: accidentally jumps to FETCH_HEAD --- lua/dep.lua | 75 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 29 deletions(-) (limited to 'lua') diff --git a/lua/dep.lua b/lua/dep.lua index 911ceca..dbf6516 100644 --- a/lua/dep.lua +++ b/lua/dep.lua @@ -494,37 +494,54 @@ local function sync(package, cb) log_err(before) cb(err) else - local function continue(err, message) - if err then - log_err(message) - cb(err) - else - proc.git_rev_parse(package.dir, "FETCH_HEAD", function(err, after) - if err then - log_err(after) - cb(err) - elseif before == after then - logger:log("skip", string.format("skipped %s", package.id)) - cb(err) - else - proc.git_reset(package.dir, after, function(err, message) - if err then - log_err(message) - else - mark_reconfigure(package) - logger:log("update", string.format("updated %s; %s -> %s", package.id, before, after)) - end - - cb(err) - end) - end - end) - end - end if package.commit then - proc.git_checkout(package.dir, package.branch, package.commit, continue) + proc.git_checkout(package.dir, package.branch, package.commit, function(err, message) + if err then + log_err(message) + cb(err) + else + proc.git_rev_parse(package.dir, package.commit, function(err, after) + if err then + log_err(after) + cb(err) + elseif before == after then + logger:log("skip", string.format("skipped %s", package.id)) + cb(err) + else + mark_reconfigure(package) + logger:log("update", string.format("updated %s; %s -> %s", package.id, before, after)) + end + end) + end + end) else - proc.git_fetch(package.dir, "origin", package.branch or "HEAD", continue) + proc.git_fetch(package.dir, "origin", package.branch or "HEAD", function(err, message) + if err then + log_err(message) + cb(err) + else + proc.git_rev_parse(package.dir, "FETCH_HEAD", function(err, after) + if err then + log_err(after) + cb(err) + elseif before == after then + logger:log("skip", string.format("skipped %s", package.id)) + cb(err) + else + proc.git_reset(package.dir, after, function(err, message) + if err then + log_err(message) + else + mark_reconfigure(package) + logger:log("update", string.format("updated %s; %s -> %s", package.id, before, after)) + end + + cb(err) + end) + end + end) + end + end) end end end) -- cgit v1.2.1