diff --git a/app/models/repository.rb b/app/models/repository.rb index cc46ab916c70560333ae5f1b8bec43ff2fdb0fd2..dc7cd926745da7d1533f8af702a82b05af0df676 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -210,9 +210,13 @@ class Repository def license cache.fetch(:license) do - tree(:head).blobs.find_all do |file| - file.name =~ /\A(copying|license)/i - end.last # Prefer `LICENSE` as filename over `COPYING` + licenses = tree(:head).blobs.find_all do |file| + file.name =~ /\A(copying|license)/i + end + + # If `licence`, `copying` and `copying.lesser` are found, return in the + # following order: licence, copying, copying.lesser + licenses.find { |l| l =~ /\Alicence/i } || licenses.sort.first end end