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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-10 03:13:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-10 03:13:05 +0300
commit1b47b087e6c36f8dc38162d7712f01173c7b85cf (patch)
tree425c32d6068a1f5742db8227cb53d3206393dfae /app/controllers
parent85e524e496ae52652c541e98d5837b7c04bd2607 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects_controller.rb3
-rw-r--r--app/controllers/repositories/lfs_api_controller.rb25
2 files changed, 27 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 04c40826d13..6af46e22d8f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -119,7 +119,10 @@ class ProjectsController < Projects::ApplicationController
if @project.errors[:new_namespace].present?
flash[:alert] = @project.errors[:new_namespace].first
+ return redirect_to edit_project_path(@project)
end
+
+ render_edit
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/controllers/repositories/lfs_api_controller.rb b/app/controllers/repositories/lfs_api_controller.rb
index 30cafb6747e..c8e44bc8399 100644
--- a/app/controllers/repositories/lfs_api_controller.rb
+++ b/app/controllers/repositories/lfs_api_controller.rb
@@ -76,7 +76,10 @@ module Repositories
existing_oids = project.lfs_objects_oids(oids: objects_oids)
objects.each do |object|
- object[:actions] = upload_actions(object) unless existing_oids.include?(object[:oid])
+ next if existing_oids.include?(object[:oid])
+ next if should_auto_link? && oids_from_fork.include?(object[:oid]) && link_to_project!(object)
+
+ object[:actions] = upload_actions(object)
end
objects
@@ -150,6 +153,26 @@ module Repositories
Gitlab::LfsToken.new(user).basic_encoding
end
+
+ def should_auto_link?
+ return false unless Feature.enabled?(:lfs_auto_link_fork_source, project)
+ return false unless project.forked?
+
+ # Sanity check in case for some reason the user doesn't have access to the parent
+ can?(user, :download_code, project.fork_source)
+ end
+
+ def oids_from_fork
+ @oids_from_fork ||= project.lfs_objects_oids_from_fork_source(oids: objects_oids)
+ end
+
+ def link_to_project!(object)
+ lfs_object = LfsObject.for_oid_and_size(object[:oid], object[:size])
+
+ return unless lfs_object
+
+ LfsObjectsProject.link_to_project!(lfs_object, project)
+ end
end
end