Skip to content

Commit 60dbc00

Browse files
committed
chore: mark commitish imports as unsupported
1 parent cd33dc6 commit 60dbc00

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

lib/travis/imports.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const internals = {
1515

1616
internals.normalizeImports = (travisYaml, { relativeTo }) => {
1717

18+
const context = relativeTo ? relativeTo.source : '.travis.yml';
19+
1820
return Utils.toArray(travisYaml.import)
1921
.map((entry) => {
2022

@@ -40,7 +42,11 @@ internals.normalizeImports = (travisYaml, { relativeTo }) => {
4042
}
4143

4244
if (!internals.validMergeModes.has(entry.mode)) {
43-
throw new Error(`Invalid merge mode for ${original} in ${relativeTo ? relativeTo.source : '.travis.yml'}: ${entry.mode}`);
45+
throw new Error(`Invalid merge mode for ${original} in ${context}: ${entry.mode}`);
46+
}
47+
48+
if (original.includes('@')) {
49+
throw new Error(`Importing at commitish unsupported in ${context}: ${original}`);
4450
}
4551

4652
return entry;

test/fixtures/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = class TestContext {
9393
if (partials) {
9494
Fs.mkdirSync(Path.join(this.path, 'partials'));
9595
const partialYmls = [
96+
'commitish.yml',
9697
'indirect-node-14.yml',
9798
'merge-invalid.yml',
9899
'node-10.yml',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
import:
3+
- source: partials/commitish.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
import:
3+
- source: partials/node-14.yml@main

test/travis.js

+20
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,26 @@ describe('.travis.yml parsing', () => {
258258

259259
await expect(NodeSupport.detect({ path: fixture.path })).to.reject('Invalid merge mode for partials/node-12.yml in partials/merge-invalid.yml: no_such_merge_mode');
260260
});
261+
262+
it('throws when importing at commitish', async () => {
263+
264+
await fixture.setupRepoFolder({
265+
partials: true,
266+
travisYml: `testing-imports/partials/commitish.yml`
267+
});
268+
269+
await expect(NodeSupport.detect({ path: fixture.path })).to.reject('Importing at commitish unsupported in .travis.yml: partials/node-14.yml@main');
270+
});
271+
272+
it('throws when importing at commitish (indirect)', async () => {
273+
274+
await fixture.setupRepoFolder({
275+
partials: true,
276+
travisYml: `testing-imports/commitish.yml`
277+
});
278+
279+
await expect(NodeSupport.detect({ path: fixture.path })).to.reject('Importing at commitish unsupported in partials/commitish.yml: partials/node-14.yml@main');
280+
});
261281
});
262282

263283
describe('Travis merging algorithms', () => {

0 commit comments

Comments
 (0)