From 9ec32b1cacdd411cbdcc262f7b327c6bfc552735 Mon Sep 17 00:00:00 2001
From: Zeger-Jan van de Weg <mail@zjvandeweg.nl>
Date: Mon, 21 Sep 2015 10:14:38 +0200
Subject: [PATCH] Prefer Licence over Copying

---
 app/models/repository.rb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/models/repository.rb b/app/models/repository.rb
index cc46ab916c7..dc7cd926745 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
 
-- 
GitLab