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 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'lua/dep.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) -- cgit v1.2.1