diff --git a/init.lua b/init.lua index 1e9ffb8..ca73e96 100644 --- a/init.lua +++ b/init.lua @@ -420,6 +420,17 @@ M._detect_conflicts = detect_conflicts -- C — dirty : commits-past-tag or working-tree dirty → warn -- D — wrong-tag : describe != pinned-tag → silent checkout -- E — broken : describe fails entirely → error +-- F — packaged : lib dir exists, no .git/, manifest.lib version +-- matches pin → accept (cmake-staged install) +local function manifest_version_matches(lib_dir, expected_version) + local f = io.open(lib_dir .. "/manifest.lib", "rb") + if not f then return false end + local content = f:read("*a") + f:close() + local m, _ = json_decode(content) + return m ~= nil and m.version == expected_version +end + local function run_state_check(unique_closure, install_root, gitea_base, warnings, errors) local git = require("lib-core.git") @@ -430,14 +441,21 @@ local function run_state_check(unique_closure, install_root, local pinned = "v" .. e.version if not git.is_repo(lib_dir) then - -- Case A: clone @ pinned-tag. - local ok, gerr = git.clone(url, lib_dir, pinned) - if not ok then - table.insert(errors, { - lib_id = e.lib_id, - kind = "net-fail", - message = tostring(gerr), - }) + -- No .git dir present. Two sub-cases: + -- F — packaged install: dir exists with a manifest.lib at + -- the right version (cmake --install layout). Accept. + -- A — missing: dir absent or manifest mismatch → clone. + if manifest_version_matches(lib_dir, e.version) then + -- Case F: packaged install, no action needed. + else + local ok, gerr = git.clone(url, lib_dir, pinned) + if not ok then + table.insert(errors, { + lib_id = e.lib_id, + kind = "net-fail", + message = tostring(gerr), + }) + end end else local desc, derr = git.describe(lib_dir) diff --git a/manifest.lib b/manifest.lib index b6b8be6..487fc26 100644 --- a/manifest.lib +++ b/manifest.lib @@ -1,6 +1,6 @@ { "id": "lib-management.dep-fetcher", - "version": "0.1.0", + "version": "0.1.1", "api_min": "0.1", "deps": [ {"id": "lib-core.git", "version": "0.1.0"}