Commit 8a936997 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

GitHooks scaffold

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8d2755a2
class Projects::GitHooksController < Projects::ApplicationController
# Authorize
before_filter :authorize_admin_project!
respond_to :html
layout "project_settings"
def index
project.create_git_hook unless project.git_hook
@pre_receive_hook = project.git_hook
end
def update
@pre_receive_hook = project.git_hook
@pre_receive_hook.update_attributes(params[:git_hook])
if @pre_receive_hook.valid?
redirect_to project_git_hooks_path(@project)
else
render :index
end
end
end
......@@ -19,6 +19,10 @@
= link_to project_hooks_path(@project) do
%i.icon-link
Web Hooks
= nav_link(controller: :git_hooks) do
= link_to project_git_hooks_path(@project) do
%i.icon-upload
Git Hooks
= nav_link(controller: :services) do
= link_to project_services_path(@project) do
%i.icon-cogs
......
%h3.page-title
Pre-receive hook
%p.light
The first script to run when handling a push from a client is pre-receive hook.
%hr.clearfix
= form_for [@project, @pre_receive_hook], html: { class: 'form-horizontal' } do |f|
-if @pre_receive_hook.errors.any?
.alert.alert-danger
- @pre_receive_hook.errors.full_messages.each do |msg|
%p= msg
.form-group
= f.label :deny_delete_tag, "Deny tag remove", class: 'control-label'
.col-sm-10
.checkbox
= f.check_box :deny_delete_tag
%span.descr Dont allow users to remove git tags
.form-group
= f.label :force_push_regex, "Force push", class: 'control-label'
.col-sm-10
= f.text_field :force_push_regex, class: "form-control"
%p.hint Regular expression for branches to allow force push. Empty - allow force push to any branch
.form-group
= f.label :delete_branch_regex, "Branch removal", class: 'control-label'
.col-sm-10
= f.text_field :delete_branch_regex, class: "form-control"
%p.hint Regular expression for branches that can be removed. Empty - allow remove of any branch
.form-group
= f.label :commit_message_regex, "Commit message", class: 'control-label'
.col-sm-10
= f.text_field :commit_message_regex, class: "form-control"
%p.hint Commit message must match this regular expression to be pushed. Empty - allow remove of any commit message
.form-actions
= f.submit "Save git Hook", class: "btn btn-create"
......@@ -291,6 +291,8 @@ Gitlab::Application.routes.draw do
end
end
resources :git_hooks, constraints: {id: /\d+/}
resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
member do
get :test
......
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