Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions lib/git-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions lib/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lib/lookup.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@
},
"undici": {
"prefix": "v",
"useGitClone": true,
"submodules": ["test/fixtures/cache-tests"],
"envVar": { "CITGM": true },
"scripts": [
"generate-pem",
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/custom-lookup-useGitClone.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"lodash": {
"prefix": "v",
"useGitClone": true
"useGitClone": true,
"submodules": ["test/fixtures"]
}
}
3 changes: 2 additions & 1 deletion test/test-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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();
});

Expand Down
Loading