Commit 6ad514d0 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix/import-project-hooks' into 'master'

fix repo hooks missing on import

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19556 

Repo hooks are missing from imported projects

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5549
parents dac2e0c4 32d8aa6d
...@@ -37,6 +37,7 @@ v 8.11.0 (unreleased) ...@@ -37,6 +37,7 @@ v 8.11.0 (unreleased)
- Reduce number of queries made for merge_requests/:id/diffs - Reduce number of queries made for merge_requests/:id/diffs
v 8.10.3 (unreleased) v 8.10.3 (unreleased)
- Fix hooks missing on imported GitLab projects
v 8.10.2 v 8.10.2
- User can now search branches by name. !5144 - User can now search branches by name. !5144
......
...@@ -17,6 +17,10 @@ module Gitlab ...@@ -17,6 +17,10 @@ module Gitlab
execute(%W(#{git_bin_path} clone --bare #{bundle_path} #{repo_path})) execute(%W(#{git_bin_path} clone --bare #{bundle_path} #{repo_path}))
end end
def git_restore_hooks
execute(%W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args)
end
private private
def tar_with_options(archive:, dir:, options:) def tar_with_options(archive:, dir:, options:)
...@@ -45,6 +49,10 @@ module Gitlab ...@@ -45,6 +49,10 @@ module Gitlab
FileUtils.copy_entry(source, destination) FileUtils.copy_entry(source, destination)
true true
end end
def repository_storage_paths_args
Gitlab.config.repositories.storages.values
end
end end
end end
end end
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
FileUtils.mkdir_p(path_to_repo) 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 rescue => e
@shared.error(e) @shared.error(e)
false false
...@@ -29,6 +29,16 @@ module Gitlab ...@@ -29,6 +29,16 @@ module Gitlab
def path_to_repo def path_to_repo
@project.repository.path_to_repo @project.repository.path_to_repo
end end
def repo_restore_hooks
return true if wiki?
git_restore_hooks
end
def wiki?
@project.class.name == 'ProjectWiki'
end
end end
end end
end end
...@@ -8,6 +8,7 @@ feature 'project import', feature: true, js: true do ...@@ -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(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
let(:export_path) { "#{Dir::tmpdir}/import_file_spec" } let(:export_path) { "#{Dir::tmpdir}/import_file_spec" }
let(:project) { Project.last } let(:project) { Project.last }
let(:project_hook) { Gitlab::Git::Hook.new('post-receive', project.repository.path) }
background do background do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) 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 ...@@ -37,7 +38,7 @@ feature 'project import', feature: true, js: true do
expect(project).not_to be_nil expect(project).not_to be_nil
expect(project.issues).not_to be_empty expect(project.issues).not_to be_empty
expect(project.merge_requests).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(wiki_exists?).to be true
expect(project.import_status).to eq('finished') expect(project.import_status).to eq('finished')
end 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