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

update_remote_mirror_service.rb « projects « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8183a2f26d708fb5f7cbda76a9fb0336579f092e (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
module Projects
  class UpdateRemoteMirrorService < BaseService
    attr_reader :errors

    def execute(remote_mirror)
      @errors = []

      return success unless remote_mirror.enabled?

      begin
        repository.fetch_remote(remote_mirror.remote_name, no_tags: true)

        opts = {}
        if remote_mirror.only_protected_branches?
          opts[:only_branches_matching] = project.protected_branches.select(:name).map(&:name)
        end

        remote_mirror.update_repository(opts)
      rescue => e
        errors << e.message.strip
      end

      if errors.present?
        error(errors.join("\n\n"))
      else
        success
      end
    end
  end
end