@@ -4,24 +4,20 @@ local fs = require("fs")
44local env = require (" env" )
55local path = require (" path" )
66local json = require (" json" )
7+ local git2 = require (" git2-sys" )
78
89local lde = require (" lde-core" )
910
1011local ldecli = require (" tests.lib.ldecli" )
1112
1213test .it (" should not ignore --git in ldx" , function ()
13- -- Pre-populate the git cache so no real download happens.
14- -- Clean up any existing cache entries for this repo name first.
15- local cacheDir = lde .global .getGitCacheDir ()
16- if fs .isdir (cacheDir ) then
17- for entry in fs .readdir (cacheDir ) do
18- if entry .name :match (" ^hood%-" ) then
19- fs .rmdir (path .join (cacheDir , entry .name ))
20- end
21- end
22- end
23-
24- local repoDir = lde .global .getGitRepoDir (" hood" , " abc1234567890abcdef1234567890abcdef123456" )
14+ local cloneUrl = " https://github.com/codebycruz/hood"
15+
16+ -- Resolve the real commit so the cache key matches what getOrCloneRepo expects.
17+ local commit = assert (git2 .lsRemote (cloneUrl , " HEAD" ))
18+
19+ -- Pre-populate the cache with a fake repo that lacks a "triangle" package.
20+ local repoDir = lde .global .getGitRepoDir (" hood" , commit )
2521 fs .rmdir (repoDir )
2622 fs .mkdir (repoDir )
2723 fs .write (path .join (repoDir , " lde.json" ), json .encode ({
@@ -32,7 +28,7 @@ test.it("should not ignore --git in ldx", function()
3228 fs .mkdir (path .join (repoDir , " src" ))
3329 fs .write (path .join (repoDir , " src" , " init.lua" ), " " )
3430
35- local _ , out = ldecli { " x" , " triangle" , " --git" , " https://github.com/codebycruz/hood " }
31+ local _ , out = ldecli { " x" , " triangle" , " --git" , cloneUrl }
3632 test .falsy (out :find (" not found in lde registry" ))
3733 test .includes (out , " No package named 'triangle'" )
3834
0 commit comments