summaryrefslogtreecommitdiff
path: root/lib/gitlab/shell.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-01-10 10:09:57 +0000
committerDouwe Maan <douwe@gitlab.com>2018-01-10 10:09:57 +0000
commited2c9797e18bce3a0d12715774c61c42e3c47f4e (patch)
treecbcb1428c9ba5b861ad1de4f8724a410d6b1f917 /lib/gitlab/shell.rb
parent6a2521d2e9ce9e8ec30b9caffdefdb9510823410 (diff)
parent58e17bf3b04f7bd63bca6b36a44b61ff2851f99e (diff)
downloadgitlab-ce-ed2c9797e18bce3a0d12715774c61c42e3c47f4e.tar.gz
Merge branch 'zj-migrate-gitlab-project-rm-mv' into 'master'
Migrate GitlabProject (re)move project endpoints Closes gitaly#873 See merge request gitlab-org/gitlab-ce!16249
Diffstat (limited to 'lib/gitlab/shell.rb')
-rw-r--r--lib/gitlab/shell.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index 392f66c99d3..f4a41dc3eda 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -136,7 +136,10 @@ module Gitlab
end
end
- # Move repository
+ # Move repository reroutes to mv_directory which is an alias for
+ # mv_namespace. Given the underlying implementation is a move action,
+ # indescriminate of what the folders might be.
+ #
# storage - project's storage path
# path - project disk path
# new_path - new project disk path
@@ -146,7 +149,9 @@ module Gitlab
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/873
def mv_repository(storage, path, new_path)
- gitlab_projects(storage, "#{path}.git").mv_project("#{new_path}.git")
+ return false if path.empty? || new_path.empty?
+
+ !!mv_directory(storage, "#{path}.git", "#{new_path}.git")
end
# Fork repository to new path
@@ -164,7 +169,9 @@ module Gitlab
.fork_repository(forked_to_storage, "#{forked_to_disk_path}.git")
end
- # Remove repository from file system
+ # Removes a repository from file system, using rm_diretory which is an alias
+ # for rm_namespace. Given the underlying implementation removes the name
+ # passed as second argument on the passed storage.
#
# storage - project's storage path
# name - project disk path
@@ -174,7 +181,12 @@ module Gitlab
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/873
def remove_repository(storage, name)
- gitlab_projects(storage, "#{name}.git").rm_project
+ return false if name.empty?
+
+ !!rm_directory(storage, "#{name}.git")
+ rescue ArgumentError => e
+ Rails.logger.warn("Repository does not exist: #{e} at: #{name}.git")
+ false
end
# Add new key to gitlab-shell
@@ -313,6 +325,7 @@ module Gitlab
rescue GRPC::InvalidArgument => e
raise ArgumentError, e.message
end
+ alias_method :rm_directory, :rm_namespace
# Move namespace directory inside repositories storage
#
@@ -332,6 +345,7 @@ module Gitlab
rescue GRPC::InvalidArgument
false
end
+ alias_method :mv_directory, :mv_namespace
def url_to_repo(path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"