summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-07-28 16:28:12 +0200
committerJames Lopez <james@jameslopez.es>2016-07-28 17:41:17 +0200
commit32d8aa6d5e1a6dbcd861a4e5baa24c3a873b57fe (patch)
treeaa8b7b86303ad1bfe9ce8723447dad6896d12893
parent273bea975baabfbdcd831a0ff525f2ace48fb750 (diff)
downloadgitlab-ce-fix/import-project-hooks.tar.gz
fix repo hooks missing on importfix/import-project-hooks
fix spec and added changelog
-rw-r--r--CHANGELOG1
-rw-r--r--lib/gitlab/import_export/command_line_util.rb8
-rw-r--r--lib/gitlab/import_export/repo_restorer.rb12
-rw-r--r--spec/features/projects/import_export/import_file_spec.rb3
4 files changed, 22 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 288adccbba2..b5f1b1a56b0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,7 @@ v 8.11.0 (unreleased)
- Change requests_profiles resource constraint to catch virtually any file
v 8.10.3 (unreleased)
+ - Fix hooks missing on imported GitLab projects
v 8.10.2
- User can now search branches by name. !5144
diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb
index 5dd0e34c18e..e522a0fc8f6 100644
--- a/lib/gitlab/import_export/command_line_util.rb
+++ b/lib/gitlab/import_export/command_line_util.rb
@@ -17,6 +17,10 @@ module Gitlab
execute(%W(#{git_bin_path} clone --bare #{bundle_path} #{repo_path}))
end
+ def git_restore_hooks
+ execute(%W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args)
+ end
+
private
def tar_with_options(archive:, dir:, options:)
@@ -45,6 +49,10 @@ module Gitlab
FileUtils.copy_entry(source, destination)
true
end
+
+ def repository_storage_paths_args
+ Gitlab.config.repositories.storages.values
+ end
end
end
end
diff --git a/lib/gitlab/import_export/repo_restorer.rb b/lib/gitlab/import_export/repo_restorer.rb
index f84de652a57..6d9379acf25 100644
--- a/lib/gitlab/import_export/repo_restorer.rb
+++ b/lib/gitlab/import_export/repo_restorer.rb
@@ -14,7 +14,7 @@ module Gitlab
FileUtils.mkdir_p(path_to_repo)
- git_unbundle(repo_path: path_to_repo, bundle_path: @path_to_bundle)
+ git_unbundle(repo_path: path_to_repo, bundle_path: @path_to_bundle) && repo_restore_hooks
rescue => e
@shared.error(e)
false
@@ -29,6 +29,16 @@ module Gitlab
def path_to_repo
@project.repository.path_to_repo
end
+
+ def repo_restore_hooks
+ return true if wiki?
+
+ git_restore_hooks
+ end
+
+ def wiki?
+ @project.class.name == 'ProjectWiki'
+ end
end
end
end
diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb
index 2d1e3bbebe5..7835e1678ad 100644
--- a/spec/features/projects/import_export/import_file_spec.rb
+++ b/spec/features/projects/import_export/import_file_spec.rb
@@ -8,6 +8,7 @@ feature 'project import', feature: true, js: true do
let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
let(:export_path) { "#{Dir::tmpdir}/import_file_spec" }
let(:project) { Project.last }
+ let(:project_hook) { Gitlab::Git::Hook.new('post-receive', project.repository.path) }
background do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
@@ -37,7 +38,7 @@ feature 'project import', feature: true, js: true do
expect(project).not_to be_nil
expect(project.issues).not_to be_empty
expect(project.merge_requests).not_to be_empty
- expect(project.repo_exists?).to be true
+ expect(project_hook).to exist
expect(wiki_exists?).to be true
expect(project.import_status).to eq('finished')
end