Commit ca9098d8982041ba76402c80c9018beb10836db8
1 parent
e90277f9
Exists in
master
and in
4 other branches
remove last commit widget, added repo size and owner info on project home page
Showing
5 changed files
with
37 additions
and
17 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -59,7 +59,6 @@ class ProjectsController < ProjectResourceController |
| 59 | 59 | format.html do |
| 60 | 60 | if @project.repository && !@project.repository.empty? |
| 61 | 61 | @last_push = current_user.recent_push(@project.id) |
| 62 | - @last_commit = CommitDecorator.decorate(@project.repository.commit) | |
| 63 | 62 | render :show |
| 64 | 63 | else |
| 65 | 64 | render "projects/empty" | ... | ... |
app/models/repository.rb
| 1 | 1 | class Repository |
| 2 | + include Gitlab::Popen | |
| 3 | + | |
| 2 | 4 | # Repository directory name with namespace direcotry |
| 3 | 5 | # Examples: |
| 4 | 6 | # gitlab/gitolite |
| ... | ... | @@ -147,4 +149,21 @@ class Repository |
| 147 | 149 | |
| 148 | 150 | file_path |
| 149 | 151 | end |
| 152 | + | |
| 153 | + # Return repo size in megabytes | |
| 154 | + # Cached in redis | |
| 155 | + def size | |
| 156 | + Rails.cache.fetch(cache_key(:size)) do | |
| 157 | + size = popen('du -s', path_to_repo).first.strip.to_i | |
| 158 | + (size.to_f / 1024).round(2) | |
| 159 | + end | |
| 160 | + end | |
| 161 | + | |
| 162 | + def expire_cache | |
| 163 | + Rails.cache.delete(cache_key(:size)) | |
| 164 | + end | |
| 165 | + | |
| 166 | + def cache_key(type) | |
| 167 | + "#{type}:#{path_with_namespace}" | |
| 168 | + end | |
| 150 | 169 | end | ... | ... |
app/services/git_push_service.rb
app/views/projects/_last_commit.html.haml
| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | -.commit | |
| 2 | - %p | |
| 3 | - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") } | |
| 4 | - = time_ago_in_words(commit.committed_date) | |
| 5 | - ago | |
| 6 | - | |
| 7 | - = commit.author_link avatar: true, size: 16 | |
| 8 | - %p | |
| 9 | - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" | |
| 10 | - | |
| 11 | - = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, commit.id), class: "row_title" |
app/views/projects/show.html.haml
| ... | ... | @@ -3,19 +3,31 @@ |
| 3 | 3 | = render "events/event_last_push", event: @last_push |
| 4 | 4 | |
| 5 | 5 | .row |
| 6 | - .span8 | |
| 6 | + .span9 | |
| 7 | 7 | .content_list= render @events |
| 8 | 8 | .loading.hide |
| 9 | - .span4 | |
| 9 | + .span3 | |
| 10 | 10 | .ui-box.white |
| 11 | 11 | .padded |
| 12 | 12 | %h3.page_title |
| 13 | 13 | = @project.name |
| 14 | - %hr | |
| 15 | 14 | - if @project.description.present? |
| 16 | 15 | %p.light= @project.description |
| 17 | 16 | |
| 18 | - %h5 Last commit: | |
| 19 | - = render 'last_commit', commit: @last_commit | |
| 17 | + %hr | |
| 18 | + %p | |
| 19 | + Access level: | |
| 20 | + - if @project.public | |
| 21 | + %span.cblue | |
| 22 | + %i.icon-share | |
| 23 | + Public | |
| 24 | + - else | |
| 25 | + %span.cgreen | |
| 26 | + %i.icon-lock | |
| 27 | + Private | |
| 28 | + | |
| 29 | + %p Repo Size: #{@project.repository.size} MB | |
| 30 | + %p Created at: #{@project.created_at.stamp('Aug 22, 2013')} | |
| 31 | + %p Owner: #{link_to @project.owner_name, @project.owner} | |
| 20 | 32 | :javascript |
| 21 | 33 | $(function(){ Pager.init(20); }); | ... | ... |