diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-09-28 20:07:22 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-09-29 19:27:06 +0300 |
commit | e5fecc3a377c458e49751e3d2eacfb52972e59c6 (patch) | |
tree | 9cee02474e9348d99f85d30acea61aafb7a46046 /lib/gitlab/shell.rb | |
parent | c49d19a5dc058a670bdac1e23579fbb44c60bec4 (diff) |
Create repositories via Gitaly
Diffstat (limited to 'lib/gitlab/shell.rb')
-rw-r--r-- | lib/gitlab/shell.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 81ecdf43ef9..a99f8e2b5f8 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -65,7 +65,7 @@ module Gitlab # Init new repository # - # storage - project's storage path + # storage - project's storage name # name - project path with namespace # # Ex. @@ -73,7 +73,19 @@ module Gitlab # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387 def add_repository(storage, name) - Gitlab::Git::Repository.create(storage, name, bare: true, symlink_hooks_to: gitlab_shell_hooks_path) + relative_path = name.dup + relative_path << '.git' unless relative_path.end_with?('.git') + + gitaly_migrate(:create_repository) do |is_enabled| + if is_enabled + repository = Gitlab::Git::Repository.new(storage, relative_path, '') + repository.gitaly_repository_client.create_repository + true + else + repo_path = File.join(Gitlab.config.repositories.storages[storage]['path'], relative_path) + Gitlab::Git::Repository.create(repo_path, bare: true, symlink_hooks_to: gitlab_shell_hooks_path) + end + end rescue => err Rails.logger.error("Failed to add repository #{storage}/#{name}: #{err}") false |