diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-05-08 23:33:12 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-05-08 23:33:12 +0300 |
commit | c92f1d893cc5f114ec1e00251b3d1dcec78fab28 (patch) | |
tree | 8935a699fba25feb3ce0672acacf89c4e7836e2e /app/services/projects/update_remote_mirror_service.rb | |
parent | 4babf79aa1e8e2ec315f31fba0d3646825322d91 (diff) | |
parent | d122279fb0a28f248e6cdba339cb1bcd96a91477 (diff) |
Merge branch '10-8-stable-prepare-rc4' into '10-8-stable'
Prepare 10.8 RC4 release
See merge request gitlab-org/gitlab-ce!18784
Diffstat (limited to 'app/services/projects/update_remote_mirror_service.rb')
-rw-r--r-- | app/services/projects/update_remote_mirror_service.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/services/projects/update_remote_mirror_service.rb b/app/services/projects/update_remote_mirror_service.rb new file mode 100644 index 00000000000..8183a2f26d7 --- /dev/null +++ b/app/services/projects/update_remote_mirror_service.rb @@ -0,0 +1,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 |