Commit 7352f8d2 authored by Valery Sizov's avatar Valery Sizov

Merge branch 'es_wiki_on_push' into ee_master

parents 74e960e5 3a45e27e
......@@ -4,6 +4,7 @@ v 8.6.0 (unreleased)
- [Elastic] Add elastic checker to gitlab:check
- [Elastic] Added UPDATE_INDEX option to rake task
- [Elasticsearch] Removing repository and wiki index after removing project
- [Elastic] Update index on push to wiki
v 8.5.1
- Fix adding pages domain to projects in groups
......
......@@ -14,6 +14,8 @@ class PostReceive
repo_path.gsub!(/\.git\z/, "")
repo_path.gsub!(/\A\//, "")
update_wiki_es_indexes(repo_path)
project = Project.find_with_namespace(repo_path)
if project.nil?
......@@ -59,4 +61,14 @@ class PostReceive
def log(message)
Gitlab::GitLogger.error("POST-RECEIVE: #{message}")
end
def update_wiki_es_indexes(repo_path)
return unless repo_path =~ /wiki\z/ && Gitlab.config.elasticsearch.enabled
project = Project.find_with_namespace(repo_path.gsub(/\.wiki\z/, ""))
if project
project.wiki.index_blobs
end
end
end
......@@ -21,6 +21,17 @@ describe PostReceive do
PostReceive.new.perform(pwd(project), key_id, base64_changes)
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(Project).to receive(:find_with_namespace).with("#{project.path_with_namespace}.wiki").and_return(nil)
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
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