Commit 32d8aa6d authored by James Lopez's avatar James Lopez

fix repo hooks missing on import

 fix spec and added changelog
parent 273bea97
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment