summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-02-28 17:27:22 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-03-07 21:59:39 +0100
commit73535b80b246248e932e6a88c462bc827d510e24 (patch)
tree51d762fdaa73e39a548d5d8195f3bb0d5f8625bd
parent903aa7c95e82949ca0a7b18e1f6d2f25fe1b04f4 (diff)
downloadgitlab-ce-73535b80b246248e932e6a88c462bc827d510e24.tar.gz
adds language names to projects list github style
-rw-r--r--app/models/project.rb9
-rw-r--r--app/views/shared/projects/_project.html.haml3
2 files changed, 12 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 3235a1cee50..2fdd4bfbbc1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -945,4 +945,13 @@ class Project < ActiveRecord::Base
def wiki
@wiki ||= ProjectWiki.new(self, self.owner)
end
+
+ def main_language
+ if !empty_repo?
+ languages = Linguist::Repository.new(
+ @repository.rugged,
+ @repository.rugged.head.target_id).languages
+ return languages.key(languages.values.max)
+ end
+ end
end
diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml
index 99e48e86e38..97cfb76cdb0 100644
--- a/app/views/shared/projects/_project.html.haml
+++ b/app/views/shared/projects/_project.html.haml
@@ -28,6 +28,9 @@
= project.name
.controls
+ - if project.main_language
+ %span
+ = project.main_language
- if ci_commit
%span
= render_ci_status(ci_commit)