Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/forks_controller.rb')
-rw-r--r--app/controllers/projects/forks_controller.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 005bc2a385b..b999110181b 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -44,13 +44,17 @@ class Projects::ForksController < Projects::ApplicationController
def new
respond_to do |format|
format.html do
- @own_namespace = current_user.namespace if fork_service.valid_fork_targets.include?(current_user.namespace)
+ @own_namespace = current_user.namespace if can_fork_to?(current_user.namespace)
@project = project
end
format.json do
namespaces = load_namespaces_with_associations - [project.namespace]
+ namespaces = [current_user.namespace] + namespaces if
+ Feature.enabled?(:fork_project_form, project, default_enabled: :yaml) &&
+ can_fork_to?(current_user.namespace)
+
render json: {
namespaces: ForkNamespaceSerializer.new.represent(namespaces, project: project, current_user: current_user, memberships: memberships_hash)
}
@@ -78,6 +82,10 @@ class Projects::ForksController < Projects::ApplicationController
private
+ def can_fork_to?(namespace)
+ ForkTargetsFinder.new(@project, current_user).execute.id_in(current_user.namespace).any?
+ end
+
def load_forks
forks = ForkProjectsFinder.new(
project,