Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
12160237
Commit
12160237
authored
Feb 10, 2020
by
mo khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct licenses with invalid spdx identifier
parent
22065fbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
ee/app/workers/import_software_licenses_worker.rb
ee/app/workers/import_software_licenses_worker.rb
+7
-7
ee/spec/workers/import_software_licenses_worker_spec.rb
ee/spec/workers/import_software_licenses_worker_spec.rb
+10
-0
No files found.
ee/app/workers/import_software_licenses_worker.rb
View file @
12160237
...
...
@@ -8,8 +8,8 @@ class ImportSoftwareLicensesWorker
def
perform
catalogue
.
each
do
|
spdx_license
|
if
unknown_
licenses
[
spdx_license
.
name
]
unknown_
licenses_with
(
spdx_license
.
name
)
if
licenses
[
spdx_license
.
name
]
licenses_with
(
spdx_license
.
name
)
.
update_all
(
spdx_identifier:
spdx_license
.
id
)
else
SoftwareLicense
.
safe_find_or_create_by!
(
...
...
@@ -22,13 +22,13 @@ class ImportSoftwareLicensesWorker
private
def
unknown_
licenses
@
unknown_
licenses
||=
unknown_
licenses_with
(
catalogue
.
map
(
&
:name
)).
grouped_by_name
.
count
def
licenses
@licenses
||=
licenses_with
(
catalogue
.
map
(
&
:name
)).
grouped_by_name
.
count
end
def
unknown_
licenses_with
(
name
)
SoftwareLicense
.
unknown
.
by_name
(
name
)
def
licenses_with
(
name
)
SoftwareLicense
.
by_name
(
name
)
end
def
catalogue
...
...
ee/spec/workers/import_software_licenses_worker_spec.rb
View file @
12160237
...
...
@@ -39,5 +39,15 @@ describe ImportSoftwareLicensesWorker do
expect
{
subject
.
perform
}.
not_to
change
(
SoftwareLicense
,
:count
)
end
end
context
'when a license has an invalid SPDX identifier'
do
before
do
apache
.
update_column
(
:spdx_identifier
,
'invalid'
)
subject
.
perform
end
it
{
expect
(
apache
.
reload
.
spdx_identifier
).
to
eql
(
spdx_apache_license
.
id
)
}
it
{
expect
(
SoftwareLicense
.
pluck
(
:spdx_identifier
)).
to
contain_exactly
(
spdx_apache_license
.
id
,
spdx_mit_license
.
id
,
spdx_bsd_license
.
id
)
}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment