Commit 8a650f5d4aada203465f8b343b5fef9789425cbd
Exists in
master
and in
4 other branches
Merge branch 'feature/readme_link' of /home/git/repositories/gitlab/gitlabhq
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/models/repository.rb
| ... | ... | @@ -133,6 +133,7 @@ class Repository |
| 133 | 133 | Rails.cache.delete(cache_key(:tag_names)) |
| 134 | 134 | Rails.cache.delete(cache_key(:commit_count)) |
| 135 | 135 | Rails.cache.delete(cache_key(:graph_log)) |
| 136 | + Rails.cache.delete(cache_key(:readme)) | |
| 136 | 137 | end |
| 137 | 138 | |
| 138 | 139 | def graph_log |
| ... | ... | @@ -159,4 +160,10 @@ class Repository |
| 159 | 160 | def blob_at(sha, path) |
| 160 | 161 | Gitlab::Git::Blob.find(self, sha, path) |
| 161 | 162 | end |
| 163 | + | |
| 164 | + def readme | |
| 165 | + Rails.cache.fetch(cache_key(:readme)) do | |
| 166 | + Tree.new(self, self.root_ref).readme | |
| 167 | + end | |
| 168 | + end | |
| 162 | 169 | end | ... | ... |
app/views/projects/show.html.haml
| ... | ... | @@ -31,6 +31,12 @@ |
| 31 | 31 | %span Download |
| 32 | 32 | = link_to project_compare_index_path(@project, from: @repository.root_ref, to: @ref || @repository.root_ref), class: 'btn btn-block' do |
| 33 | 33 | Compare code |
| 34 | + | |
| 35 | + - if @repository.readme | |
| 36 | + - readme = @repository.readme | |
| 37 | + = link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do | |
| 38 | + = readme.name | |
| 39 | + | |
| 34 | 40 | .prepend-top-10 |
| 35 | 41 | %p |
| 36 | 42 | %span.light Created on | ... | ... |