Merge pull request #155 from kachick/fix-154
Ignore removed changes in license checker
This commit is contained in:
@@ -68,3 +68,31 @@ test('it fails all license checks when allow is provided an empty array', async
|
|||||||
})
|
})
|
||||||
expect(invalidChanges.length).toBe(2)
|
expect(invalidChanges.length).toBe(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('it does not fail if a license outside the allow list is found in removed changes', async () => {
|
||||||
|
const changes: Changes = [
|
||||||
|
{...npmChange, change_type: 'removed'},
|
||||||
|
{...rubyChange, change_type: 'removed'}
|
||||||
|
]
|
||||||
|
const [invalidChanges, _] = getDeniedLicenseChanges(changes, {allow: ['BSD']})
|
||||||
|
expect(invalidChanges).toStrictEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('it does not fail if a license inside the deny list is found in removed changes', async () => {
|
||||||
|
const changes: Changes = [
|
||||||
|
{...npmChange, change_type: 'removed'},
|
||||||
|
{...rubyChange, change_type: 'removed'}
|
||||||
|
]
|
||||||
|
const [invalidChanges, _] = getDeniedLicenseChanges(changes, {deny: ['BSD']})
|
||||||
|
expect(invalidChanges).toStrictEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('it fails if a license outside the allow list is found in both of added and removed changes', async () => {
|
||||||
|
const changes: Changes = [
|
||||||
|
{...npmChange, change_type: 'removed'},
|
||||||
|
npmChange,
|
||||||
|
{...rubyChange, change_type: 'removed'}
|
||||||
|
]
|
||||||
|
const [invalidChanges, _] = getDeniedLicenseChanges(changes, {allow: ['BSD']})
|
||||||
|
expect(invalidChanges).toStrictEqual([npmChange])
|
||||||
|
})
|
||||||
|
|||||||
+3
@@ -85,6 +85,9 @@ function getDeniedLicenseChanges(changes, licenses) {
|
|||||||
const disallowed = [];
|
const disallowed = [];
|
||||||
const unknown = [];
|
const unknown = [];
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
|
if (change.change_type === 'removed') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const license = change.license;
|
const license = change.license;
|
||||||
if (license === null) {
|
if (license === null) {
|
||||||
unknown.push(change);
|
unknown.push(change);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -25,6 +25,10 @@ export function getDeniedLicenseChanges(
|
|||||||
const unknown: Change[] = []
|
const unknown: Change[] = []
|
||||||
|
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
|
if (change.change_type === 'removed') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const license = change.license
|
const license = change.license
|
||||||
if (license === null) {
|
if (license === null) {
|
||||||
unknown.push(change)
|
unknown.push(change)
|
||||||
|
|||||||
Reference in New Issue
Block a user