From ff112ce641a93f38647e67e4ed92b685ccc2430a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 4 Jul 2018 14:42:24 +0200 Subject: Add Repository#set_config and #delete_config --- lib/gitlab/gitaly_client/repository_service.rb | 49 +++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'lib/gitlab/gitaly_client/repository_service.rb') diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 982f8d0963b..64b9af4d70c 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -265,17 +265,39 @@ module Gitlab true end - def write_config(full_path:) - request = Gitaly::WriteConfigRequest.new(repository: @gitaly_repo, full_path: full_path) - response = GitalyClient.call( + def set_config(entries) + return if entries.empty? + + request = Gitaly::SetConfigRequest.new(repository: @gitaly_repo) + entries.each do |key, value| + request.entries << build_set_config_entry(key, value) + end + + GitalyClient.call( + @storage, + :repository_service, + :set_config, + request, + timeout: GitalyClient.fast_timeout + ) + + nil + end + + def delete_config(keys) + return if keys.empty? + + request = Gitaly::DeleteConfigRequest.new(repository: @gitaly_repo, keys: keys) + + GitalyClient.call( @storage, :repository_service, - :write_config, + :delete_config, request, timeout: GitalyClient.fast_timeout ) - raise Gitlab::Git::OSError.new(response.error) unless response.error.empty? + nil end def license_short_name @@ -352,6 +374,23 @@ module Gitlab timeout: timeout ) end + + def build_set_config_entry(key, value) + entry = Gitaly::SetConfigRequest::Entry.new(key: key) + + case value + when String + entry.value_str = value + when Integer + entry.value_int32 = value + when TrueClass, FalseClass + entry.value_bool = value + else + raise InvalidArgument, "invalid git config value: #{value.inspect}" + end + + entry + end end end end -- cgit v1.2.3