diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2018-01-26 09:00:22 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2018-01-31 15:02:31 +0100 |
commit | 28bbb4cb47ebb8669643e8fad34b75ea34f18e36 (patch) | |
tree | 32c95526b1d3061806f7c89daf1b465b7260bc55 /lib | |
parent | 08e013431acb5238b4806260c4b9c304837097a3 (diff) | |
download | gitlab-ce-28bbb4cb47ebb8669643e8fad34b75ea34f18e36.tar.gz |
Migrate Gitlab::Git::Repository#write_config to Gitalygitaly-970-repo-write-config
- Add tests for Repository#write_config
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 13 |
3 files changed, 27 insertions, 1 deletions
diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb index 71647099f83..9e8caa259d2 100644 --- a/lib/gitlab/git.rb +++ b/lib/gitlab/git.rb @@ -6,6 +6,7 @@ module Gitlab CommandError = Class.new(StandardError) CommitError = Class.new(StandardError) + OSError = Class.new(StandardError) class << self include Gitlab::EncodingHelper diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 8137c582c0f..8ba12808c10 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1311,7 +1311,15 @@ module Gitlab # rubocop:enable Metrics/ParameterLists def write_config(full_path:) - rugged.config['gitlab.fullpath'] = full_path if full_path.present? + return unless full_path.present? + + gitaly_migrate(:write_config) do |is_enabled| + if is_enabled + gitaly_repository_client.write_config(full_path: full_path) + else + rugged_write_config(full_path: full_path) + end + end end def gitaly_repository @@ -1451,6 +1459,10 @@ module Gitlab end end + def rugged_write_config(full_path:) + rugged.config['gitlab.fullpath'] = full_path + end + def shell_write_ref(ref_path, ref, old_ref) raise ArgumentError, "invalid ref_path #{ref_path.inspect}" if ref_path.include?(' ') raise ArgumentError, "invalid ref #{ref.inspect}" if ref.include?("\x00") diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 7adf32af209..60706b4f0d8 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -219,6 +219,19 @@ module Gitlab true end + + def write_config(full_path:) + request = Gitaly::WriteConfigRequest.new(repository: @gitaly_repo, full_path: full_path) + response = GitalyClient.call( + @storage, + :repository_service, + :write_config, + request, + timeout: GitalyClient.fast_timeout + ) + + raise Gitlab::Git::OSError.new(response.error) unless response.error.empty? + end end end end |