Skip to content

Commit 18cf7df

Browse files
authored
lib: log correct version and sha for -c option (#1026)
When using the -c option to supply a specific sha to test CITGM will erroneously log the latest version of the module. This commit overrides the incorrect value with the one that is in the downloaded package.json. Additionally, when supplying -c CITGM will now output the sha for easier debugging.
1 parent 9c19fe2 commit 18cf7df

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

lib/citgm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export class Tester extends EventEmitter {
112112
flaky: this.module.flaky,
113113
expectFail: this.module.expectFail
114114
};
115+
116+
if (this.options.sha) payload.sha = this.module.sha;
117+
115118
if (err) {
116119
if (!payload.expectFail) {
117120
this.emit('fail', err);

lib/lookup.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ export function lookup(context) {
143143
context.module.ref = ref;
144144
} else {
145145
const gitHead = rep.head || rep.ignoreGitHead ? null : meta.gitHead;
146+
const sha = context.options.sha || rep.sha || gitHead;
146147
const url = makeUrl(
147148
getRepo(rep.repo, meta),
148149
rep.head ? null : detail.fetchSpec,
149150
meta['dist-tags'],
150151
rep.head ? null : rep.prefix,
151-
context.options.sha || rep.sha || gitHead
152+
sha
152153
);
153154
context.emit(
154155
'data',
@@ -197,16 +198,12 @@ export function lookup(context) {
197198
: defaultMatcher.isMatch(rep.expectFail);
198199
} else {
199200
context.emit('data', 'info', 'lookup-notfound', detail.name);
201+
const sha = context.options.sha || meta.gitHead;
200202
if (meta.gitHead) {
201-
const url = makeUrl(
202-
getRepo(null, meta),
203-
null,
204-
null,
205-
null,
206-
context.options.sha || meta.gitHead
207-
);
203+
const url = makeUrl(getRepo(null, meta), null, null, null, sha);
208204
context.emit('data', 'info', 'lookup-githead', url);
209205
context.module.raw = url;
206+
context.module.sha = sha;
210207
}
211208
}
212209
}

lib/package-manager/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export async function test(packageManager, context) {
3333
let data;
3434
try {
3535
data = await readPackage(join(wd, 'package.json'), false);
36+
// Explicitly set the version to the value in the downloaded package.json.
37+
context.module.version = data.version;
3638
} catch (err) {
3739
throw new Error('Package.json Could not be found');
3840
}

lib/reporter/logger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function logModule(log, logType, module) {
88
log[logType](chalk.yellow('module name:'), module.name);
99
if (!module.skipped) {
1010
log[logType](chalk.yellow('version:'), module.version);
11+
12+
if (module.sha) log[logType](chalk.yellow('sha:'), module.sha);
1113
}
1214
if (module.error) {
1315
if (!module.testOutput) module.testOutput = '';

0 commit comments

Comments
 (0)