summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-11 10:33:03 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-11 10:33:03 +0100
commitcd97dba2a9a26e83818f7e111bc0b0185a7ced8a (patch)
tree23195397edc1d24b527f793b4275087320c14cd5 /app
parent73942b15e775d34ea3563545942978a726c5f28e (diff)
parenta2798e8d06641be61e8a44682984c2d4b123e70f (diff)
downloadgitlab-ce-cd97dba2a9a26e83818f7e111bc0b0185a7ced8a.tar.gz
Merge branch 'zj/gitlab-ce-copying-file-seen-as-licence'
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 1edec52c09e..2c25f4ce451 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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