2014-11-13 15:06:19 -05:00
|
|
|
class Projects::ForksController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
2014-11-13 15:06:19 -05:00
|
|
|
|
|
|
|
def new
|
|
|
|
@namespaces = current_user.manageable_namespaces
|
|
|
|
@namespaces.delete(@project.namespace)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-01-24 13:02:58 -05:00
|
|
|
namespace = Namespace.find(params[:namespace_key])
|
2014-11-13 15:06:19 -05:00
|
|
|
@forked_project = ::Projects::ForkService.new(project, current_user, namespace: namespace).execute
|
|
|
|
|
|
|
|
if @forked_project.saved? && @forked_project.forked?
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to(
|
|
|
|
namespace_project_path(@forked_project.namespace, @forked_project),
|
|
|
|
notice: 'Project was successfully forked.'
|
|
|
|
)
|
2014-11-13 15:06:19 -05:00
|
|
|
else
|
|
|
|
render :error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|