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

container_moved.rb « checks « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 41180bbf2467859869406ce299c3f3f6ebe6a57c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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