mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 20:24:51 +00:00
Don't allow empty changed-files objects through
This commit is contained in:
@@ -159,6 +159,15 @@ describe('toChangedFilesMatchConfig', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('but it has empty values', () => {
|
||||||
|
const config = {'changed-files': []};
|
||||||
|
|
||||||
|
it(`returns an empty object`, () => {
|
||||||
|
const result = toChangedFilesMatchConfig(config);
|
||||||
|
expect(result).toEqual<ChangedFilesMatchConfig>({});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('and there is an unknown value in the config', () => {
|
describe('and there is an unknown value in the config', () => {
|
||||||
const config = {'changed-files': [{any: 'testing'}, {sneaky: 'test'}]};
|
const config = {'changed-files': [{any: 'testing'}, {sneaky: 'test'}]};
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ export function toChangedFilesMatchConfig(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (Array.isArray(changedFilesConfig)) {
|
if (Array.isArray(changedFilesConfig)) {
|
||||||
if (changedFilesConfig.every(entry => typeof entry === 'string')) {
|
if (
|
||||||
|
changedFilesConfig.length &&
|
||||||
|
changedFilesConfig.every(entry => typeof entry === 'string')
|
||||||
|
) {
|
||||||
changedFilesMatchConfig.changedFiles = {
|
changedFilesMatchConfig.changedFiles = {
|
||||||
any: changedFilesConfig
|
any: changedFilesConfig
|
||||||
};
|
};
|
||||||
@@ -80,6 +83,11 @@ export function toChangedFilesMatchConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no items were added to `changedFiles` then return an empty object
|
||||||
|
if (!Object.keys(changedFilesMatchConfig.changedFiles).length) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
return changedFilesMatchConfig;
|
return changedFilesMatchConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user