Class: Gitlab::GitalyClient::RemoteService
- Inherits:
-
Object
- Object
- Gitlab::GitalyClient::RemoteService
- Includes:
- EncodingHelper, WithFeatureFlagActors
- Defined in:
- lib/gitlab/gitaly_client/remote_service.rb
Constant Summary collapse
- MAX_MSG_SIZE =
128.kilobytes.freeze
Constants included from EncodingHelper
EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER
Instance Attribute Summary
Attributes included from WithFeatureFlagActors
Class Method Summary collapse
Instance Method Summary collapse
- #find_remote_root_ref(remote_url, authorization) ⇒ Object
-
#initialize(repository) ⇒ RemoteService
constructor
A new instance of RemoteService.
- #update_remote_mirror(remote_url, only_branches_matching, ssh_key: nil, known_hosts: nil, keep_divergent_refs: false) ⇒ Object
Methods included from WithFeatureFlagActors
#gitaly_client_call, #gitaly_feature_flag_actors, #group_actor, #project_actor, #user_actor
Methods included from EncodingHelper
#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #strip_bom, #unquote_path
Constructor Details
#initialize(repository) ⇒ RemoteService
Returns a new instance of RemoteService.
24 25 26 27 28 29 30 |
# File 'lib/gitlab/gitaly_client/remote_service.rb', line 24 def initialize(repository) @repository = repository @gitaly_repo = repository.gitaly_repository @storage = repository.storage self.repository_actor = repository end |
Class Method Details
.exists?(remote_url) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/gitaly_client/remote_service.rb', line 11 def self.exists?(remote_url) storage = GitalyClient.random_storage request = Gitaly::FindRemoteRepositoryRequest.new(remote: remote_url, storage_name: storage) response = GitalyClient.call(storage, :remote_service, :find_remote_repository, request, timeout: GitalyClient.medium_timeout) response.exists end |
Instance Method Details
#find_remote_root_ref(remote_url, authorization) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab/gitaly_client/remote_service.rb', line 32 def find_remote_root_ref(remote_url, ) request = Gitaly::FindRemoteRootRefRequest.new(repository: @gitaly_repo, remote_url: remote_url, http_authorization_header: ) response = gitaly_client_call(@storage, :remote_service, :find_remote_root_ref, request, timeout: GitalyClient.medium_timeout) encode_utf8(response.ref) end |
#update_remote_mirror(remote_url, only_branches_matching, ssh_key: nil, known_hosts: nil, keep_divergent_refs: false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gitlab/gitaly_client/remote_service.rb', line 43 def update_remote_mirror(remote_url, only_branches_matching, ssh_key: nil, known_hosts: nil, keep_divergent_refs: false) req_enum = Enumerator.new do |y| first_request = Gitaly::UpdateRemoteMirrorRequest.new( repository: @gitaly_repo ) first_request.remote = Gitaly::UpdateRemoteMirrorRequest::Remote.new(url: remote_url) first_request.ssh_key = ssh_key if ssh_key.present? first_request.known_hosts = known_hosts if known_hosts.present? first_request.keep_divergent_refs = keep_divergent_refs y.yield(first_request) current_size = 0 slices = only_branches_matching.slice_before do |branch_name| current_size += branch_name.bytesize next false if current_size < MAX_MSG_SIZE current_size = 0 end slices.each do |slice| y.yield Gitaly::UpdateRemoteMirrorRequest.new(only_branches_matching: slice) end end GitalyClient.call(@storage, :remote_service, :update_remote_mirror, req_enum, timeout: GitalyClient.long_timeout) end |