Commit 17f6a916 authored by Jeroen Nijhof's avatar Jeroen Nijhof

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
parents f394ccd5 706255b9
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.4.0 (unreleased) v 8.4.0 (unreleased)
- Add housekeeping function to project settings page
- The default GitLab logo now acts as a loading indicator - The default GitLab logo now acts as a loading indicator
- Accept 2xx status codes for successful Web hook triggers (Stan Hu) - 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) - Fix missing date of month in network graph when commits span a month (Stan Hu)
......
...@@ -8,7 +8,7 @@ class ProjectsController < ApplicationController ...@@ -8,7 +8,7 @@ class ProjectsController < ApplicationController
before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists?
# Authorize # 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] before_action :event_filter, only: [:show, :activity]
layout :determine_layout layout :determine_layout
...@@ -166,6 +166,15 @@ class ProjectsController < ApplicationController ...@@ -166,6 +166,15 @@ class ProjectsController < ApplicationController
end end
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 def toggle_star
current_user.toggle_star(@project) current_user.toggle_star(@project)
@project.reload @project.reload
......
# 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
...@@ -174,6 +174,19 @@ ...@@ -174,6 +174,19 @@
.danger-settings .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 can? current_user, :archive_project, @project
- if @project.archived? - if @project.archived?
.panel.panel-success .panel.panel-success
......
...@@ -375,6 +375,7 @@ Rails.application.routes.draw do ...@@ -375,6 +375,7 @@ Rails.application.routes.draw do
delete :remove_fork delete :remove_fork
post :archive post :archive
post :unarchive post :unarchive
post :housekeeping
post :toggle_star post :toggle_star
post :markdown_preview post :markdown_preview
get :autocomplete_sources get :autocomplete_sources
......
...@@ -150,6 +150,18 @@ module Gitlab ...@@ -150,6 +150,18 @@ module Gitlab
"#{path}.git", tag_name]) "#{path}.git", tag_name])
end 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 # Add new key to gitlab-shell
# #
# Ex. # Ex.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment