Skip to content

Commit 5ed0dfa

Browse files
committed
chore: mark commitish imports as unsupported
1 parent 193cd1e commit 5ed0dfa

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

lib/travis/imports.js

Lines changed: 7 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
import:
3+
- source: partials/commitish.yml
Lines changed: 3 additions & 0 deletions
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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@ describe('.travis.yml parsing', () => {
253253

254254
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');
255255
});
256+
257+
it('throws when importing at commitish', async () => {
258+
259+
await fixture.setupRepoFolder({
260+
partials: true,
261+
travisYml: `testing-imports/partials/commitish.yml`
262+
});
263+
264+
await expect(NodeSupport.detect({ path: fixture.path })).to.reject('Importing at commitish unsupported in .travis.yml: partials/node-14.yml@main');
265+
});
266+
267+
it('throws when importing at commitish (indirect)', async () => {
268+
269+
await fixture.setupRepoFolder({
270+
partials: true,
271+
travisYml: `testing-imports/commitish.yml`
272+
});
273+
274+
await expect(NodeSupport.detect({ path: fixture.path })).to.reject('Importing at commitish unsupported in partials/commitish.yml: partials/node-14.yml@main');
275+
});
256276
});
257277

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

0 commit comments

Comments
 (0)