diff --git a/README.md b/README.md index 22c3ad8f..96073d7b 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ For syntax, see [lookup.json](./lib/lookup.json), the available attributes are: "scripts": ["script1", "script2"] - List of scripts from package.json to run instead of 'test' "tags": ["tag1", "tag2"] Specify which tags apply to the module "useGitClone": true Use a shallow git clone instead of downloading the module +"submodules": ["path/to/submodule"] Initialize only the listed submodules when using a git clone "ignoreGitHead": Ignore the gitHead field if it exists and fallback to using github tags "yarn": Install and test the project using yarn instead of npm "pnpm": Install and test the project using pnpm instead of npm diff --git a/lib/git-clone.js b/lib/git-clone.js index 8cb9c6dc..26177e61 100644 --- a/lib/git-clone.js +++ b/lib/git-clone.js @@ -24,8 +24,15 @@ export async function gitClone(context) { await execGit(['remote', 'add', 'origin', gitUrl]); await execGit(['fetch', '--depth=1', 'origin', gitRef]); await execGit(['checkout', 'FETCH_HEAD']); - await execGit(['submodule', 'init']); - await execGit(['submodule', 'update']); + if (context.module.submodules) { + const submodules = Array.isArray(context.module.submodules) + ? context.module.submodules + : [context.module.submodules]; + await execGit(['submodule', 'update', '--init', '--', ...submodules]); + } else { + await execGit(['submodule', 'init']); + await execGit(['submodule', 'update']); + } context.unpack = false; } diff --git a/lib/lookup.js b/lib/lookup.js index 34921785..94434888 100644 --- a/lib/lookup.js +++ b/lib/lookup.js @@ -190,6 +190,9 @@ export function lookup(context) { if (rep.timeout) { context.module.timeout = rep.timeout; } + if (rep.submodules) { + context.module.submodules = rep.submodules; + } context.module.flaky = context.options.failFlaky ? false : defaultMatcher.isMatch(rep.flaky); diff --git a/lib/lookup.json b/lib/lookup.json index 5b587b71..53710741 100644 --- a/lib/lookup.json +++ b/lib/lookup.json @@ -440,6 +440,8 @@ }, "undici": { "prefix": "v", + "useGitClone": true, + "submodules": ["test/fixtures/cache-tests"], "envVar": { "CITGM": true }, "scripts": [ "generate-pem", diff --git a/test/fixtures/custom-lookup-useGitClone.json b/test/fixtures/custom-lookup-useGitClone.json index 5a8f7e98..63d2c826 100644 --- a/test/fixtures/custom-lookup-useGitClone.json +++ b/test/fixtures/custom-lookup-useGitClone.json @@ -1,6 +1,7 @@ { "lodash": { "prefix": "v", - "useGitClone": true + "useGitClone": true, + "submodules": ["test/fixtures"] } } diff --git a/test/test-lookup.js b/test/test-lookup.js index aff7fb2f..3aa0e217 100644 --- a/test/test-lookup.js +++ b/test/test-lookup.js @@ -245,7 +245,7 @@ test('lookup: module in table with scripts', (t) => { }); test('lookup: module in table with useGitClone', (t) => { - t.plan(2); + t.plan(3); const context = { lookup: null, module: parsePackageArg('lodash'), @@ -269,6 +269,7 @@ test('lookup: module in table with useGitClone', (t) => { 'raw should be a git URL if useGitClone is true' ); t.equal(context.module.ref, 'v1.2.3'); + t.strictSame(context.module.submodules, ['test/fixtures']); t.end(); });