summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-10-16 09:48:55 +0300
committerrandx <dmitriy.zaporozhets@gmail.com>2012-10-16 09:48:55 +0300
commit76e1ca64301d52fb25b0a0e8cb9d513ba7d33c46 (patch)
treef2b12b59b6a13403a160412755b7733e410a1171
parent453b2ae68b1f127de1deeb745950132542eac667 (diff)
downloadgitlab-ce-76e1ca64301d52fb25b0a0e8cb9d513ba7d33c46.tar.gz
tree.readme method added
-rw-r--r--app/decorators/tree_decorator.rb4
-rw-r--r--app/views/tree/_tree.html.haml4
2 files changed, 6 insertions, 2 deletions
diff --git a/app/decorators/tree_decorator.rb b/app/decorators/tree_decorator.rb
index 5a7b13abfee..eb3859a990e 100644
--- a/app/decorators/tree_decorator.rb
+++ b/app/decorators/tree_decorator.rb
@@ -28,4 +28,8 @@ class TreeDecorator < ApplicationDecorator
file = File.join(path, "..")
h.project_tree_path(project, h.tree_join(ref, file))
end
+
+ def readme
+ @readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
+ end
end
diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml
index 71192109b8f..02ae3d90c40 100644
--- a/app/views/tree/_tree.html.haml
+++ b/app/views/tree/_tree.html.haml
@@ -32,8 +32,8 @@
= render_tree(tree.contents)
- - if readme = tree.contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
- = render "tree/readme", readme: readme
+ - if tree.readme
+ = render "tree/readme", readme: tree.readme
- unless tree.is_blob?
:javascript