mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 05:06:46 +10:00
Add option to mirror an upstream repository. Closes internal https://dev.gitlab.org/gitlab/gitlab-ee/issues/279 Depends on gitlab-org/gitlab-shell!29 To do: - [x] Decide on what user should be the author of the activity feed events. The initial project creator perhaps? That makes sense for personal projects, but less so for group projects, where it's even possible that the creator has since left the team. - [x] Write specs! - [x] Write documentation - [x] Port back relevant commits to CE: gitlab-org/gitlab-ce!1822 ---- ## Mirror status on project homepage  ## Settings navigation item  ## Mirroring settings  ## Activity feed with new "pushes" (mirror updates)  I have yet to decide on what user should be the author of these events. The initial project creator perhaps? That makes sense for personal projects, but less so for group projects, where it's even possible that the creator has since left the team. ## Warning that branch has diverged from upstream  ## Commits heading after failed update  Link send user to the mirroring settings if they are a project admin. ## Mirroring settings after failed update  ## New project page  ## Import form after failed import (Screenshot outdated)  Shown when the initial import of a project fails, not when an update of an existing project fails. cc @dzaporozhets @sytses @JobV See merge request !51
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
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."
|
|
elsif @project.mirror_changed?
|
|
flash[:notice] = "Mirroring was successfully disabled."
|
|
else
|
|
flash[:notice] = "Mirroring settings were successfully updated."
|
|
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, :mirror_user_id)
|
|
end
|
|
end
|