add ability to specifiy commit ref
This commit is contained in:
@ -95,6 +95,10 @@ A package must be declared in the following format.
|
|||||||
-- Defaults to whatever the remote configured as their HEAD, which is usually "master".
|
-- Defaults to whatever the remote configured as their HEAD, which is usually "master".
|
||||||
branch = "develop",
|
branch = "develop",
|
||||||
|
|
||||||
|
-- [string] Overrides the commit ref to target
|
||||||
|
-- Defaults to the latest commit on the current branch
|
||||||
|
commit = "e76cb03",
|
||||||
|
|
||||||
-- [boolean] Prevents the package from being loaded.
|
-- [boolean] Prevents the package from being loaded.
|
||||||
disable = true,
|
disable = true,
|
||||||
|
|
||||||
|
28
lua/dep.lua
28
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.url = spec.url or package.url or ("https://github.com/" .. id .. ".git")
|
||||||
package.branch = spec.branch or package.branch
|
package.branch = spec.branch or package.branch
|
||||||
package.dir = base_dir .. package.name
|
package.dir = base_dir .. package.name
|
||||||
|
package.commit = spec.commit
|
||||||
package.pin = overrides.pin or spec.pin or package.pin
|
package.pin = overrides.pin or spec.pin or package.pin
|
||||||
package.enabled = not overrides.disable and not spec.disable and package.enabled
|
package.enabled = not overrides.disable and not spec.disable and package.enabled
|
||||||
|
|
||||||
@ -493,7 +494,7 @@ local function sync(package, cb)
|
|||||||
log_err(before)
|
log_err(before)
|
||||||
cb(err)
|
cb(err)
|
||||||
else
|
else
|
||||||
proc.git_fetch(package.dir, "origin", package.branch or "HEAD", function(err, message)
|
local function continue(err, message)
|
||||||
if err then
|
if err then
|
||||||
log_err(message)
|
log_err(message)
|
||||||
cb(err)
|
cb(err)
|
||||||
@ -519,7 +520,12 @@ local function sync(package, cb)
|
|||||||
end
|
end
|
||||||
end)
|
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
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
@ -527,9 +533,21 @@ local function sync(package, cb)
|
|||||||
if err then
|
if err then
|
||||||
logger:log("error", string.format("failed to install %s; reason: %s", package.id, message))
|
logger:log("error", string.format("failed to install %s; reason: %s", package.id, message))
|
||||||
else
|
else
|
||||||
package.exists = true
|
if package.commit then
|
||||||
mark_reconfigure(package)
|
proc.git_checkout(package.dir, package.branch, package.commit, function(err, message)
|
||||||
logger:log("install", string.format("installed %s", package.id))
|
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
|
end
|
||||||
|
|
||||||
cb(err)
|
cb(err)
|
||||||
|
@ -61,4 +61,14 @@ function proc.git_reset(dir, treeish, cb)
|
|||||||
proc.exec("git", args, dir, git_env, cb)
|
proc.exec("git", args, dir, git_env, cb)
|
||||||
end
|
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
|
return proc
|
||||||
|
Reference in New Issue
Block a user