Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2018-03-15 23:01:48 +0300
committerClement Ho <ClemMakesApps@gmail.com>2018-03-15 23:03:01 +0300
commit51d3a9a2416b2f431e1db76c0642806475ea7db7 (patch)
treece9bc3c57100096fd92778abcb088dd7f7a18fc0 /lib
parent4615a1adf642ed9ef2bb00ead1040da8a8745f12 (diff)
parentbac30796fe3f22265729418df239dcf4461d8475 (diff)
Merge branch 'csslab' into login-page-css-refactorlogin-page-css-refactor
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/relation_factory.rb9
-rw-r--r--lib/gitlab/project_transfer.rb16
-rw-r--r--lib/gitlab/shell.rb13
-rw-r--r--lib/tasks/gitlab/shell.rake2
4 files changed, 28 insertions, 12 deletions
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index cf6b7e306dd..791a54e1b69 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -70,6 +70,7 @@ module Gitlab
update_user_references
update_project_references
+ remove_duplicate_assignees
reset_tokens!
remove_encrypted_attributes!
@@ -83,6 +84,14 @@ module Gitlab
end
end
+ def remove_duplicate_assignees
+ return unless @relation_hash['issue_assignees']
+
+ # When an assignee did not exist in the members mapper, the importer is
+ # assigned. We only need to assign each user once.
+ @relation_hash['issue_assignees'].uniq!(&:user_id)
+ end
+
def setup_note
set_note_author
# attachment is deprecated and note uploads are handled by Markdown uploader
diff --git a/lib/gitlab/project_transfer.rb b/lib/gitlab/project_transfer.rb
index 1bba0b78e2f..690c38737c0 100644
--- a/lib/gitlab/project_transfer.rb
+++ b/lib/gitlab/project_transfer.rb
@@ -1,13 +1,19 @@
module Gitlab
+ # This class is used to move local, unhashed files owned by projects to their new location
class ProjectTransfer
- def move_project(project_path, namespace_path_was, namespace_path)
- new_namespace_folder = File.join(root_dir, namespace_path)
- FileUtils.mkdir_p(new_namespace_folder) unless Dir.exist?(new_namespace_folder)
- from = File.join(root_dir, namespace_path_was, project_path)
- to = File.join(root_dir, namespace_path, project_path)
+ # nil parent_path (or parent_path_was) represents a root namespace
+ def move_namespace(path, parent_path_was, parent_path)
+ parent_path_was ||= ''
+ parent_path ||= ''
+ new_parent_folder = File.join(root_dir, parent_path)
+ FileUtils.mkdir_p(new_parent_folder)
+ from = File.join(root_dir, parent_path_was, path)
+ to = File.join(root_dir, parent_path, path)
move(from, to, "")
end
+ alias_method :move_project, :move_namespace
+
def rename_project(path_was, path, namespace_path)
base_dir = File.join(root_dir, namespace_path)
move(path_was, path, base_dir)
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index dda7afc0999..3a8f5826818 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -69,13 +69,14 @@ module Gitlab
# name - project disk path
#
# Ex.
- # add_repository("/path/to/storage", "gitlab/gitlab-ci")
+ # create_repository("/path/to/storage", "gitlab/gitlab-ci")
#
- def add_repository(storage, name)
+ def create_repository(storage, name)
relative_path = name.dup
relative_path << '.git' unless relative_path.end_with?('.git')
- gitaly_migrate(:create_repository) do |is_enabled|
+ gitaly_migrate(:create_repository,
+ status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
repository = Gitlab::Git::Repository.new(storage, relative_path, '')
repository.gitaly_repository_client.create_repository
@@ -85,7 +86,7 @@ module Gitlab
Gitlab::Git::Repository.create(repo_path, bare: true, symlink_hooks_to: gitlab_shell_hooks_path)
end
end
- rescue => err
+ rescue => err # Once the Rugged codes gets removes this can be improved
Rails.logger.error("Failed to add repository #{storage}/#{name}: #{err}")
false
end
@@ -487,8 +488,8 @@ module Gitlab
Gitlab.config.gitlab_shell.git_timeout
end
- def gitaly_migrate(method, &block)
- Gitlab::GitalyClient.migrate(method, &block)
+ def gitaly_migrate(method, status: Gitlab::GitalyClient::MigrationStatus::OPT_IN, &block)
+ Gitlab::GitalyClient.migrate(method, status: status, &block)
rescue GRPC::NotFound, GRPC::BadStatus => e
# Old Popen code returns [Error, output] to the caller, so we
# need to do the same here...
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index 844664b12d4..4fcbbbf8c9d 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -69,7 +69,7 @@ namespace :gitlab do
if File.exist?(path_to_repo)
print '-'
else
- if Gitlab::Shell.new.add_repository(project.repository_storage,
+ if Gitlab::Shell.new.create_repository(project.repository_storage,
project.disk_path)
print '.'
else