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,7 +59,6 @@ class ProjectsController < ProjectResourceController | ||
59 | format.html do | 59 | format.html do |
60 | if @project.repository && !@project.repository.empty? | 60 | if @project.repository && !@project.repository.empty? |
61 | @last_push = current_user.recent_push(@project.id) | 61 | @last_push = current_user.recent_push(@project.id) |
62 | - @last_commit = CommitDecorator.decorate(@project.repository.commit) | ||
63 | render :show | 62 | render :show |
64 | else | 63 | else |
65 | render "projects/empty" | 64 | render "projects/empty" |
app/models/repository.rb
1 | class Repository | 1 | class Repository |
2 | + include Gitlab::Popen | ||
3 | + | ||
2 | # Repository directory name with namespace direcotry | 4 | # Repository directory name with namespace direcotry |
3 | # Examples: | 5 | # Examples: |
4 | # gitlab/gitolite | 6 | # gitlab/gitolite |
@@ -147,4 +149,21 @@ class Repository | @@ -147,4 +149,21 @@ class Repository | ||
147 | 149 | ||
148 | file_path | 150 | file_path |
149 | end | 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 | end | 169 | end |
app/services/git_push_service.rb
@@ -23,6 +23,7 @@ class GitPushService | @@ -23,6 +23,7 @@ class GitPushService | ||
23 | 23 | ||
24 | project.ensure_satellite_exists | 24 | project.ensure_satellite_exists |
25 | project.discover_default_branch | 25 | project.discover_default_branch |
26 | + project.repository.expire_cache | ||
26 | 27 | ||
27 | if push_to_branch?(ref, oldrev) | 28 | if push_to_branch?(ref, oldrev) |
28 | project.update_merge_requests(oldrev, newrev, ref, @user) | 29 | project.update_merge_requests(oldrev, newrev, ref, @user) |
app/views/projects/_last_commit.html.haml
@@ -1,11 +0,0 @@ | @@ -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,19 +3,31 @@ | ||
3 | = render "events/event_last_push", event: @last_push | 3 | = render "events/event_last_push", event: @last_push |
4 | 4 | ||
5 | .row | 5 | .row |
6 | - .span8 | 6 | + .span9 |
7 | .content_list= render @events | 7 | .content_list= render @events |
8 | .loading.hide | 8 | .loading.hide |
9 | - .span4 | 9 | + .span3 |
10 | .ui-box.white | 10 | .ui-box.white |
11 | .padded | 11 | .padded |
12 | %h3.page_title | 12 | %h3.page_title |
13 | = @project.name | 13 | = @project.name |
14 | - %hr | ||
15 | - if @project.description.present? | 14 | - if @project.description.present? |
16 | %p.light= @project.description | 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 | :javascript | 32 | :javascript |
21 | $(function(){ Pager.init(20); }); | 33 | $(function(){ Pager.init(20); }); |