GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 4f0a38f1 authored by Jeroen Nijhof's avatar Jeroen Nijhof

Added housekeeping for git repositories

parent 323b6eb1
......@@ -171,6 +171,14 @@ def unarchive
end
end
def housekeeping
::Projects::HousekeepingService.new(@project).execute
respond_to do |format|
format.html { redirect_to project_path(@project) }
end
end
def toggle_star
current_user.toggle_star(@project)
@project.reload
......
# Projects::HousekeepingService class
#
# Used for git housekeeping
#
# Ex.
# Projects::HousekeepingService.new(project, user).execute
#
module Projects
class HousekeepingService < BaseService
include Gitlab::ShellAdapter
def initialize(project)
@project = project
end
def execute
if gitlab_shell.exists?(@project.path_with_namespace + '.git')
gitlab_shell.gc(@project.path_with_namespace)
end
end
end
end
......@@ -141,6 +141,17 @@
- else
.nothing-here-block Only the project owner can archive a project
.panel.panel-default.panel.panel-warning
.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
= link_to 'Housekeeping', housekeeping_namespace_project_path(@project.namespace, @project),
method: :post, class: "btn btn-warning"
.panel.panel-default.panel.panel-warning
.panel-heading Rename repository
.errors-holder
......
......@@ -381,6 +381,7 @@
delete :remove_fork
post :archive
post :unarchive
post :housekeeping
post :toggle_star
post :markdown_preview
get :autocomplete_sources
......
......@@ -149,6 +149,18 @@ def rm_tag(path, tag_name)
"#{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.
......
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