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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
5fd280f3
Commit
5fd280f3
authored
Nov 12, 2015
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Licence also accepted as license file
parent
a3f64b53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
CHANGELOG
CHANGELOG
+1
-1
app/models/repository.rb
app/models/repository.rb
+15
-7
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+10
-1
No files found.
CHANGELOG
View file @
5fd280f3
...
...
@@ -32,7 +32,7 @@ v 8.2.0 (unreleased)
- Fix incoming email config defaults
- MR target branch is now visible on a list view when it is different from project's default one
- Improve Continuous Integration graphs page
- Accept COPYING
as licenc
e file (Zeger-Jan van de Weg)
- Accept COPYING
,COPYING.lesser, and licence as licens
e file (Zeger-Jan van de Weg)
v 8.1.4
- Fix bug where manually merged branches in a MR would end up with an empty diff (Stan Hu)
...
...
app/models/repository.rb
View file @
5fd280f3
...
...
@@ -244,16 +244,24 @@ class Repository
def
license
cache
.
fetch
(
:license
)
do
licenses
=
tree
(
:head
).
blobs
.
find_all
do
|
file
|
file
.
name
=~
/\A(copying|license)/i
file
.
name
=~
/\A(copying|license
|licence
)/i
end
# If `licence`, `copying` and `copying.lesser` are found, return in the
# following order: licence, copying, copying.lesser
regex
=
[
/\Alicense(\..*)?\z/i
,
/\Acopying(\..{0,3})?\z/i
,
/\Acopying.lesser/i
]
preferences
=
[
/\Alicen[sc]e\z/i
,
# LICENSE, LICENCE
/\Alicen[sc]e\./i
,
# LICENSE.md, LICENSE.txt
/\Acopying\z/i
,
# COPYING
/\Acopying\.(?!lesser)/i
,
# COPYING.txt
/Acopying.lesser/i
# COPYING.LESSER
]
license
=
nil
preferences
.
each
do
|
r
|
license
=
licenses
.
find
{
|
l
|
l
.
name
=~
r
}
break
if
license
end
regex
.
map
do
|
re
|
licenses
.
find
{
|
l
|
l
.
name
=~
re
}
end
.
compact
.
first
license
end
end
...
...
spec/models/repository_spec.rb
View file @
5fd280f3
...
...
@@ -102,13 +102,22 @@ describe Repository do
end
describe
"#license"
do
it
'test selection preference'
do
before
do
repository
.
send
(
:cache
).
expire
(
:license
)
TestBlob
=
Struct
.
new
(
:name
)
end
it
'test selection preference'
do
files
=
[
TestBlob
.
new
(
'file'
),
TestBlob
.
new
(
'license'
),
TestBlob
.
new
(
'copying'
)]
expect
(
repository
.
tree
).
to
receive
(
:blobs
).
and_return
(
files
)
expect
(
repository
.
license
.
name
).
to
eq
(
'license'
)
end
it
'also accepts licence instead of license'
do
expect
(
repository
.
tree
).
to
receive
(
:blobs
).
and_return
([
TestBlob
.
new
(
'licence'
)])
expect
(
repository
.
license
.
name
).
to
eq
(
'licence'
)
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