Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement installing packages over Git #309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libs/calculate-deps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local queryGit = require('pkg').queryGit
local normalize = require('semver').normalize

local processDeps
local db, deps
local db, deps, configs

local GIT_SCHEMES = {
"^https?://", -- over http/s protocol
Expand Down Expand Up @@ -120,7 +120,8 @@ end
local function resolveGitDep(url)
-- fetch the repo tree, don't include any tags
log("fetching", colorize("highlight", url))
local _, stderr, code = exec("git", "fetch", "--no-tags", "--depth=1", url)
local _, stderr, code = exec("git", "--git-dir=" .. configs.database,
"fetch", "--no-tags", "--depth=1", url)

-- was the fetch successful?
if code ~= 0 then
Expand All @@ -139,7 +140,8 @@ local function resolveGitDep(url)

-- query module's metadata, and match author/name
local meta, kind
meta, kind, hash = assert(queryGit(db, hash))
meta, kind, hash = queryGit(db, hash)
assert(meta, "Unable to find a valid package")
local author, name = meta.name:match("^([^/]+)/(.*)$")

-- check for installed packages and their version
Expand Down Expand Up @@ -176,10 +178,10 @@ function processDeps(dependencies)
end
end

return function (gitDb, depsMap, newDeps)
return function (gitDb, depsMap, newDeps, core)
SinisterRectus marked this conversation as resolved.
Show resolved Hide resolved
-- assign gitDb and depsMap to upvalue to be visible everywhere
-- then start processing newDeps
db, deps = gitDb, depsMap
db, deps, configs = gitDb, depsMap, core.config
processDeps(newDeps)

-- collect all deps names and log them
Expand Down
2 changes: 1 addition & 1 deletion libs/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ local function makeCore(config)

function core.installList(path, newDeps)
local deps = getInstalled(gfs, path)
calculateDeps(core.db, deps, newDeps)
calculateDeps(core.db, deps, newDeps, core)
installDepsFs(core.db, gfs, path, deps, true)
return deps
end
Expand Down