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
Jérome Perrin
gitlab-ce
Commits
cd97dba2
Commit
cd97dba2
authored
Dec 11, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj/gitlab-ce-copying-file-seen-as-licence'
parents
73942b15
a2798e8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
3 deletions
+39
-3
CHANGELOG
CHANGELOG
+1
-0
app/models/repository.rb
app/models/repository.rb
+18
-2
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+20
-1
No files found.
CHANGELOG
View file @
cd97dba2
...
...
@@ -42,6 +42,7 @@ v 8.3.0 (unreleased)
- Fix sidebar tooltips when collapsed
- Prevent possible XSS attack with award-emoji
- Upgraded Sidekiq to 4.x
- Accept COPYING,COPYING.lesser, and licence as license file (Zeger-Jan van de Weg)
v 8.2.3
- Fix application settings cache not expiring after changes (Stan Hu)
...
...
app/models/repository.rb
View file @
cd97dba2
...
...
@@ -271,9 +271,25 @@ class Repository
def
license
cache
.
fetch
(
:license
)
do
tree
(
:head
).
blobs
.
find
do
|
file
|
file
.
name
=~
/\Alicense/i
licenses
=
tree
(
:head
).
blobs
.
find_all
do
|
file
|
file
.
name
=~
/\A(copying|license|licence)/i
end
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
license
end
end
...
...
spec/models/repository_spec.rb
View file @
cd97dba2
...
...
@@ -103,6 +103,26 @@ describe Repository, models: true do
end
describe
"#license"
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
describe
:add_branch
do
context
'when pre hooks were successful'
do
it
'should run without errors'
do
...
...
@@ -199,5 +219,4 @@ describe Repository, models: true do
end
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