Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'fix-154'
Browse files Browse the repository at this point in the history
Backport actions#155
  • Loading branch information
kachick committed Jul 14, 2022
2 parents ddc70a5 + c003e7f commit 900aae4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ updates:
schedule:
interval: daily
ignore:
- dependency-name: '@types/*'
- dependency-name: '@types/node'
update-types: ['version-update:semver-major']
34 changes: 34 additions & 0 deletions __tests__/licenses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,37 @@ test('it detects unknown licenses', async () => {
})
expect(unknownLicenses.sort()).toStrictEqual([nullLicense, unknownLicense])
})

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-2-Clause']
})
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-2-Clause']
})
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-2-Clause']
})
expect(invalidChanges).toStrictEqual([npmChange])
})
6 changes: 6 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export function getDeniedLicenseChanges(
const unknown: Change[] = []

for (const change of changes) {
if (change.change_type === 'removed') {
continue
}

const license = change.license
if (license === null || !isSpdxId(license)) {
unknown.push(change)
Expand Down

0 comments on commit 900aae4

Please sign in to comment.