summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-07 11:14:19 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-07 11:14:19 +0200
commitca9098d8982041ba76402c80c9018beb10836db8 (patch)
tree75e4b3f70a809557c1bcb7f289653551ce391e60
parente90277f9b526194bacf740c352e014baa14b1f40 (diff)
downloadgitlab-ce-ca9098d8982041ba76402c80c9018beb10836db8.tar.gz
remove last commit widget, added repo size and owner info on project home page
-rw-r--r--app/controllers/projects_controller.rb1
-rw-r--r--app/models/repository.rb19
-rw-r--r--app/services/git_push_service.rb1
-rw-r--r--app/views/projects/_last_commit.html.haml11
-rw-r--r--app/views/projects/show.html.haml22
5 files changed, 37 insertions, 17 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 4588536e5fc..f703cf6bc1d 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -59,7 +59,6 @@ class ProjectsController < ProjectResourceController
format.html do
if @project.repository && !@project.repository.empty?
@last_push = current_user.recent_push(@project.id)
- @last_commit = CommitDecorator.decorate(@project.repository.commit)
render :show
else
render "projects/empty"
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 3feb3180347..934c1a6e086 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1,4 +1,6 @@
class Repository
+ include Gitlab::Popen
+
# Repository directory name with namespace direcotry
# Examples:
# gitlab/gitolite
@@ -147,4 +149,21 @@ class Repository
file_path
end
+
+ # Return repo size in megabytes
+ # Cached in redis
+ def size
+ Rails.cache.fetch(cache_key(:size)) do
+ size = popen('du -s', path_to_repo).first.strip.to_i
+ (size.to_f / 1024).round(2)
+ end
+ end
+
+ def expire_cache
+ Rails.cache.delete(cache_key(:size))
+ end
+
+ def cache_key(type)
+ "#{type}:#{path_with_namespace}"
+ end
end
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 208ccf699d2..d0b3dd557a1 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -23,6 +23,7 @@ class GitPushService
project.ensure_satellite_exists
project.discover_default_branch
+ project.repository.expire_cache
if push_to_branch?(ref, oldrev)
project.update_merge_requests(oldrev, newrev, ref, @user)
diff --git a/app/views/projects/_last_commit.html.haml b/app/views/projects/_last_commit.html.haml
deleted file mode 100644
index 5d940417c3b..00000000000
--- a/app/views/projects/_last_commit.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-.commit
- %p
- %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") }
- = time_ago_in_words(commit.committed_date)
- ago
- &nbsp;
- = commit.author_link avatar: true, size: 16
- %p
- = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id"
- &nbsp;
- = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, commit.id), class: "row_title"
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 48bed5b119f..861930cab35 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -3,19 +3,31 @@
= render "events/event_last_push", event: @last_push
.row
- .span8
+ .span9
.content_list= render @events
.loading.hide
- .span4
+ .span3
.ui-box.white
.padded
%h3.page_title
= @project.name
- %hr
- if @project.description.present?
%p.light= @project.description
- %h5 Last commit:
- = render 'last_commit', commit: @last_commit
+ %hr
+ %p
+ Access level:
+ - if @project.public
+ %span.cblue
+ %i.icon-share
+ Public
+ - else
+ %span.cgreen
+ %i.icon-lock
+ Private
+
+ %p Repo Size: #{@project.repository.size} MB
+ %p Created at: #{@project.created_at.stamp('Aug 22, 2013')}
+ %p Owner: #{link_to @project.owner_name, @project.owner}
:javascript
$(function(){ Pager.init(20); });