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-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /lib/gitlab/checks
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/container_moved.rb41
-rw-r--r--lib/gitlab/checks/lfs_check.rb4
-rw-r--r--lib/gitlab/checks/post_push_message.rb23
-rw-r--r--lib/gitlab/checks/project_created.rb12
-rw-r--r--lib/gitlab/checks/project_moved.rb33
5 files changed, 70 insertions, 43 deletions
diff --git a/lib/gitlab/checks/container_moved.rb b/lib/gitlab/checks/container_moved.rb
new file mode 100644
index 00000000000..41180bbf246
--- /dev/null
+++ b/lib/gitlab/checks/container_moved.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Checks
+ class ContainerMoved < PostPushMessage
+ REDIRECT_NAMESPACE = "redirect_namespace"
+
+ def initialize(repository, user, protocol, redirected_path)
+ @redirected_path = redirected_path
+
+ super(repository, user, protocol)
+ end
+
+ def message
+ <<~MESSAGE
+ #{container.class.model_name.human} '#{redirected_path}' was moved to '#{container.full_path}'.
+
+ Please update your Git remote:
+
+ git remote set-url origin #{url_to_repo}
+ MESSAGE
+ end
+
+ private
+
+ attr_reader :redirected_path
+
+ def self.message_key(user, repository)
+ "#{REDIRECT_NAMESPACE}:#{user.id}:#{repository.gl_repository}"
+ end
+
+ # TODO: Remove in the next release
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/292030
+ def self.legacy_message_key(user, repository)
+ return unless repository.project
+
+ "#{REDIRECT_NAMESPACE}:#{user.id}:#{repository.project.id}"
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/checks/lfs_check.rb b/lib/gitlab/checks/lfs_check.rb
index 51013b69755..84069a1249b 100644
--- a/lib/gitlab/checks/lfs_check.rb
+++ b/lib/gitlab/checks/lfs_check.rb
@@ -7,9 +7,9 @@ module Gitlab
ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'
def validate!
- # This feature flag is used for disabling integrify check on some envs
+ # This feature flag is used for disabling integrity check on some envs
# because these costy calculations may cause performance issues
- return unless Feature.enabled?(:lfs_check, default_enabled: true)
+ return unless Feature.enabled?(:lfs_check, project, default_enabled: :yaml)
return unless project.lfs_enabled?
diff --git a/lib/gitlab/checks/post_push_message.rb b/lib/gitlab/checks/post_push_message.rb
index 0d93e7ac8a1..09407f45e54 100644
--- a/lib/gitlab/checks/post_push_message.rb
+++ b/lib/gitlab/checks/post_push_message.rb
@@ -9,21 +9,32 @@ module Gitlab
@protocol = protocol
end
- def self.fetch_message(user_id, project_id)
- key = message_key(user_id, project_id)
+ def self.fetch_message(user, repository)
+ key = message_key(user, repository)
+
+ # Also check for messages in the legacy key
+ # TODO: Remove in the next release
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/292030
+ legacy_key = legacy_message_key(user, repository) if respond_to?(:legacy_message_key)
Gitlab::Redis::SharedState.with do |redis|
message = redis.get(key)
redis.del(key)
- message
+
+ if legacy_key
+ legacy_message = redis.get(legacy_key)
+ redis.del(legacy_key)
+ end
+
+ legacy_message || message
end
end
def add_message
- return unless user.present? && project.present?
+ return unless user && repository
Gitlab::Redis::SharedState.with do |redis|
- key = self.class.message_key(user.id, project.id)
+ key = self.class.message_key(user, repository)
redis.setex(key, 5.minutes, message)
end
end
@@ -39,7 +50,7 @@ module Gitlab
delegate :project, to: :repository, allow_nil: true
delegate :container, to: :repository, allow_nil: false
- def self.message_key(user_id, project_id)
+ def self.message_key(user, repository)
raise NotImplementedError
end
diff --git a/lib/gitlab/checks/project_created.rb b/lib/gitlab/checks/project_created.rb
index 362562068e9..ea3be883be6 100644
--- a/lib/gitlab/checks/project_created.rb
+++ b/lib/gitlab/checks/project_created.rb
@@ -21,8 +21,16 @@ module Gitlab
private
- def self.message_key(user_id, project_id)
- "#{PROJECT_CREATED}:#{user_id}:#{project_id}"
+ def self.message_key(user, repository)
+ "#{PROJECT_CREATED}:#{user.id}:#{repository.gl_repository}"
+ end
+
+ # TODO: Remove in the next release
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/292030
+ def self.legacy_message_key(user, repository)
+ return unless repository.project
+
+ "#{PROJECT_CREATED}:#{user.id}:#{repository.project.id}"
end
def project_url
diff --git a/lib/gitlab/checks/project_moved.rb b/lib/gitlab/checks/project_moved.rb
deleted file mode 100644
index 4cc35de9c2d..00000000000
--- a/lib/gitlab/checks/project_moved.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Checks
- class ProjectMoved < PostPushMessage
- REDIRECT_NAMESPACE = "redirect_namespace"
-
- def initialize(repository, user, protocol, redirected_path)
- @redirected_path = redirected_path
-
- super(repository, user, protocol)
- end
-
- def message
- <<~MESSAGE
- Project '#{redirected_path}' was moved to '#{project.full_path}'.
-
- Please update your Git remote:
-
- git remote set-url origin #{url_to_repo}
- MESSAGE
- end
-
- private
-
- attr_reader :redirected_path
-
- def self.message_key(user_id, project_id)
- "#{REDIRECT_NAMESPACE}:#{user_id}:#{project_id}"
- end
- end
- end
-end