diff options
author | Jeroen Nijhof <jeroen@jeroennijhof.nl> | 2016-01-11 09:13:53 +0000 |
---|---|---|
committer | Jeroen Nijhof <jeroen@jeroennijhof.nl> | 2016-01-11 09:13:53 +0000 |
commit | 17f6a916d0f6d3b687973bb9ae88e4a79f1cccf5 (patch) | |
tree | b304932262b48942a6526fdd8464f53212577134 | |
parent | f394ccd584f7c2a58a172ad4dd501045cb388e9c (diff) | |
parent | 706255b926f21588fcb11f08d1a3781c407900cd (diff) | |
download | gitlab-ce-17f6a916d0f6d3b687973bb9ae88e4a79f1cccf5.tar.gz |
Merge branch 'master' into 'master'
Added housekeeping for git repositories
This merge request will add a housekeeping button in the project setting page which invoke the gitlab shell to run a `git gc` in the project repository.
see gitlab-org/gitlab-ce#3041
Depends on gitlab-org/gitlab-shell!23 which has been merged.
See merge request !1658
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | GITLAB_SHELL_VERSION | 2 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 11 | ||||
-rw-r--r-- | app/services/projects/housekeeping_service.rb | 20 | ||||
-rw-r--r-- | app/views/projects/edit.html.haml | 13 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/backend/shell.rb | 12 |
7 files changed, 58 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 04bcbf9dad2..47f47e1228e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.4.0 (unreleased) + - Add housekeeping function to project settings page - The default GitLab logo now acts as a loading indicator - Accept 2xx status codes for successful Web hook triggers (Stan Hu) - Fix missing date of month in network graph when commits span a month (Stan Hu) diff --git a/GITLAB_SHELL_VERSION b/GITLAB_SHELL_VERSION index d48d3702aed..a04abec9149 100644 --- a/GITLAB_SHELL_VERSION +++ b/GITLAB_SHELL_VERSION @@ -1 +1 @@ -2.6.9 +2.6.10 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3004722bce0..935f7d75c6a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,7 +8,7 @@ class ProjectsController < ApplicationController before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? # Authorize - before_action :authorize_admin_project!, only: [:edit, :update] + before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping] before_action :event_filter, only: [:show, :activity] layout :determine_layout @@ -166,6 +166,15 @@ class ProjectsController < ApplicationController end end + def housekeeping + ::Projects::HousekeepingService.new(@project).execute + + respond_to do |format| + flash[:notice] = "Housekeeping successfully started." + format.html { redirect_to project_path(@project) } + end + end + def toggle_star current_user.toggle_star(@project) @project.reload diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb new file mode 100644 index 00000000000..0db85ac2142 --- /dev/null +++ b/app/services/projects/housekeeping_service.rb @@ -0,0 +1,20 @@ +# Projects::HousekeepingService class +# +# Used for git housekeeping +# +# Ex. +# Projects::HousekeepingService.new(project).execute +# +module Projects + class HousekeepingService < BaseService + include Gitlab::ShellAdapter + + def initialize(project) + @project = project + end + + def execute + GitlabShellWorker.perform_async(:gc, @project.path_with_namespace) + end + end +end diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 650629ef1b9..31e752c6649 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -174,6 +174,19 @@ .danger-settings + .panel.panel-default + .panel-heading Housekeeping + .errors-holder + .panel-body + %p + Runs a number of housekeeping tasks within the current repository, + such as compressing file revisions and removing unreachable objects. + %br + + .form-actions + = link_to 'Housekeeping', housekeeping_namespace_project_path(@project.namespace, @project), + method: :post, class: "btn btn-default" + - if can? current_user, :archive_project, @project - if @project.archived? .panel.panel-success diff --git a/config/routes.rb b/config/routes.rb index 4fcea1185c0..3d5c70987c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -375,6 +375,7 @@ Rails.application.routes.draw do delete :remove_fork post :archive post :unarchive + post :housekeeping post :toggle_star post :markdown_preview get :autocomplete_sources diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index 459e3d6bcdb..4c15d58d680 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -150,6 +150,18 @@ module Gitlab "#{path}.git", tag_name]) end + # Gc repository + # + # path - project path with namespace + # + # Ex. + # gc("gitlab/gitlab-ci") + # + def gc(path) + Gitlab::Utils.system_silent([gitlab_shell_projects_path, 'gc', + "#{path}.git"]) + end + # Add new key to gitlab-shell # # Ex. |