Commit 1d209416 authored by Valery Sizov's avatar Valery Sizov

[Elastic] Update index on push to wiki

parent 8de3358b
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0
- [Elastic] Update index on push to wiki
v 8.5.0 (unreleased) v 8.5.0 (unreleased)
- Show warning when mirror repository default branch could not be updated because it has diverged from upstream. - Show warning when mirror repository default branch could not be updated because it has diverged from upstream.
- More reliable wiki indexer - More reliable wiki indexer
......
...@@ -14,6 +14,18 @@ class PostReceive ...@@ -14,6 +14,18 @@ class PostReceive
repo_path.gsub!(/\.git\z/, "") repo_path.gsub!(/\.git\z/, "")
repo_path.gsub!(/\A\//, "") repo_path.gsub!(/\A\//, "")
if repo_path =~ /wiki\z/ && Gitlab.config.elasticsearch.enabled
repo_path.gsub!(/\.wiki\z/, "")
project = Project.find_with_namespace(repo_path)
if project
project.wiki.index_blobs
end
return false
end
project = Project.find_with_namespace(repo_path) project = Project.find_with_namespace(repo_path)
if project.nil? if project.nil?
......
...@@ -21,6 +21,16 @@ describe PostReceive do ...@@ -21,6 +21,16 @@ describe PostReceive do
PostReceive.new.perform(pwd(project), key_id, base64_changes) PostReceive.new.perform(pwd(project), key_id, base64_changes)
end end
it "triggers wiki index update" do
allow(Gitlab.config.elasticsearch).to receive(:enabled).and_return(true)
expect(Project).to receive(:find_with_namespace).with(project.path_with_namespace).and_return(project)
expect_any_instance_of(ProjectWiki).to receive(:index_blobs)
repo_path = "#{pwd(project)}.wiki"
PostReceive.new.perform(repo_path, key_id, base64_changes)
end
it "does not run if the author is not in the project" do it "does not run if the author is not in the project" do
allow(Key).to receive(:find_by).with(hash_including(id: anything())) { nil } allow(Key).to receive(:find_by).with(hash_including(id: anything())) { nil }
......
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