Commit 9098fc54 authored by Douwe Maan's avatar Douwe Maan

Add Mirror Repository to project settings.

parent 7612aae1
class Projects::MirrorsController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_admin_project!, except: [:update_now]
before_action :authorize_push_code!, only: [:update_now]
layout "project_settings"
def show
end
def update
if @project.update_attributes(mirror_params)
if @project.mirror?
@project.update_mirror
flash[:notice] = "Mirroring settings were successfully updated. The project is being updated."
else
flash[:notice] = "Mirroring was successfully disabled."
end
redirect_to namespace_project_mirror_path(@project.namespace, @project)
else
render :show
end
end
def update_now
@project.update_mirror
flash[:notice] = "The repository is being updated..."
redirect_back_or_default(default: namespace_project_path(@project.namespace, @project))
end
private
def mirror_params
params.require(:project).permit(:mirror, :import_url)
end
end
......@@ -44,6 +44,11 @@
= icon('lock fw')
%span
Protected Branches
= nav_link(controller: :mirrors) do
= link_to namespace_project_mirror_path(@project.namespace, @project), title: 'Mirror Repository', data: {placement: 'right'} do
= icon('clone fw')
%span
Mirror Repository
= nav_link(controller: :audit_events) do
= link_to namespace_project_audit_events_path(@project.namespace, @project) do
= icon('file-text-o fw')
......
- page_title "Mirror Repository"
%h3.page-title
Mirror Repository
.pull-right
= render "shared/mirror_update_button"
%p.light
Set up your project to automatically have its branches and tags updated from an upstream repository every hour.
%hr.clearfix
- if @project.mirror?
- if @project.updating_mirror?
.alert.alert-info
%p The repository is being updated...
- case @project.mirror_last_update_status
- when :success
.alert.alert-success
%p The repository was successfully updated #{time_ago_with_tooltip(@project.mirror_last_successful_update_at)}.
- when :failed
.alert.alert-danger
%p The repository failed to be updated #{time_ago_with_tooltip(@project.mirror_last_update_at)}.
%pre.prepend-top-10
:preserve
#{@project.import_error.try(:strip)}
- if @project.mirror_ever_updated_successfully?
.alert.alert-success
%p The repository was last successfully updated #{time_ago_with_tooltip(@project.mirror_last_successful_update_at)}.
= form_for @project, url: namespace_project_mirror_path(@project.namespace, @project), html: { class: 'form-horizontal' } do |f|
- if @project.errors.any?
.alert.alert-danger
- @project.errors.full_messages.each do |msg|
%p= msg
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :mirror do
= f.check_box :mirror
%strong
Mirror repository
.help-block
Automatically update this project's branches and tags from the upstream repository every hour.
.form-group
= f.label :import_url, class: 'control-label' do
%span Git repository URL
.col-sm-10
= f.text_field :import_url, class: 'form-control', placeholder: 'https://username:password@gitlab.company.com/group/project.git'
.well.prepend-top-20
%ul
%li
The repository must be accessible over <code>http://</code>, <code>https://</code>, <code>ssh://</code> or <code>git://</code>.
%li
If your HTTP repository is not publicly accessible, add authentication information to the URL: <code>https://username:password@gitlab.company.com/group/project.git</code>.
%li
If your SSH repository is not publicly accessible, add the public SSH key of the GitLab server to the remote repository.
%li
The update action will time out after 10 minutes. For big repositories, use a clone/push combination.
.form-actions
= f.submit "Save Changes", class: "btn btn-create"
- if @project.mirror? && can?(current_user, :push_code, @project)
- size = nil unless defined?(size) && size
- if @project.updating_mirror?
%span.btn.disabled{class: ("btn-#{size}" if size)}
= icon('refresh')
Updating&hellip;
- else
= link_to update_now_namespace_project_mirror_path(@project.namespace, @project), method: :post, class: "btn #{"btn-#{size}" if size}" do
= icon('refresh')
Update Now
......@@ -615,6 +615,11 @@ Gitlab::Application.routes.draw do
resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resource :mirror, only: [:show, :update] do
member do
post :update_now
end
end
resources :git_hooks, constraints: { id: /\d+/ }
resource :variables, only: [:show, :update]
resources :triggers, only: [:index, :create, :destroy]
......
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