Commit 96dd516f authored by Markus Koller's avatar Markus Koller

Merge branch '325526-fj-enable-new-wiki-destroy-page-RPC' into 'master'

Enable new wiki delete page RPC [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57106
parents cd021cb0 3111761e
...@@ -192,18 +192,11 @@ class Wiki ...@@ -192,18 +192,11 @@ class Wiki
def delete_page(page, message = nil) def delete_page(page, message = nil)
return unless page return unless page
if Feature.enabled?(:gitaly_replace_wiki_delete_page, user, default_enabled: :yaml)
capture_git_error(:deleted) do capture_git_error(:deleted) do
repository.delete_file(user, page.path, **multi_commit_options(:deleted, message, page.title)) repository.delete_file(user, page.path, **multi_commit_options(:deleted, message, page.title))
after_wiki_activity after_wiki_activity
true
end
else
wiki.delete_page(page.path, commit_details(:deleted, message, page.title))
after_wiki_activity
true true
end end
end end
......
---
title: Enable new RPC to destroy wiki pages
merge_request: 57106
author:
type: changed
---
name: gitaly_replace_wiki_delete_page
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56495
rollout_issue_url:
milestone: '13.10'
type: development
group: group::editor
default_enabled: false
...@@ -73,12 +73,6 @@ module Gitlab ...@@ -73,12 +73,6 @@ module Gitlab
end end
end end
def delete_page(page_path, commit_details)
wrapped_gitaly_errors do
gitaly_delete_page(page_path, commit_details)
end
end
def update_page(page_path, title, format, content, commit_details) def update_page(page_path, title, format, content, commit_details)
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_update_page(page_path, title, format, content, commit_details) gitaly_update_page(page_path, title, format, content, commit_details)
...@@ -140,10 +134,6 @@ module Gitlab ...@@ -140,10 +134,6 @@ module Gitlab
gitaly_wiki_client.update_page(page_path, title, format, content, commit_details) gitaly_wiki_client.update_page(page_path, title, format, content, commit_details)
end end
def gitaly_delete_page(page_path, commit_details)
gitaly_wiki_client.delete_page(page_path, commit_details)
end
def gitaly_find_page(title:, version: nil, dir: nil) def gitaly_find_page(title:, version: nil, dir: nil)
return unless title.present? return unless title.present?
......
...@@ -64,16 +64,6 @@ module Gitlab ...@@ -64,16 +64,6 @@ module Gitlab
GitalyClient.call(@repository.storage, :wiki_service, :wiki_update_page, enum, timeout: GitalyClient.medium_timeout) GitalyClient.call(@repository.storage, :wiki_service, :wiki_update_page, enum, timeout: GitalyClient.medium_timeout)
end end
def delete_page(page_path, commit_details)
request = Gitaly::WikiDeletePageRequest.new(
repository: @gitaly_repo,
page_path: encode_binary(page_path),
commit_details: gitaly_commit_details(commit_details)
)
GitalyClient.call(@repository.storage, :wiki_service, :wiki_delete_page, request, timeout: GitalyClient.medium_timeout)
end
def find_page(title:, version: nil, dir: nil) def find_page(title:, version: nil, dir: nil)
request = Gitaly::WikiFindPageRequest.new( request = Gitaly::WikiFindPageRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
......
...@@ -58,22 +58,6 @@ RSpec.describe Gitlab::Git::Wiki do ...@@ -58,22 +58,6 @@ RSpec.describe Gitlab::Git::Wiki do
end end
end end
describe '#delete_page' do
after do
destroy_page('page1')
end
it 'only removes the page with the same path' do
create_page('page1', 'content')
create_page('*', 'content')
subject.delete_page('*', commit_details('whatever'))
expect(subject.list_pages.count).to eq 1
expect(subject.list_pages.first.title).to eq 'page1'
end
end
describe '#preview_slug' do describe '#preview_slug' do
where(:title, :format, :expected_slug) do where(:title, :format, :expected_slug) do
'The Best Thing' | :markdown | 'The-Best-Thing' 'The Best Thing' | :markdown | 'The-Best-Thing'
......
...@@ -51,7 +51,7 @@ RSpec.describe Git::WikiPushService, services: true do ...@@ -51,7 +51,7 @@ RSpec.describe Git::WikiPushService, services: true do
process_changes do process_changes do
write_new_page write_new_page
update_page(wiki_page_a.title) update_page(wiki_page_a.title)
delete_page(wiki_page_b.page.path) delete_page(wiki_page_b.page)
end end
end end
...@@ -198,7 +198,7 @@ RSpec.describe Git::WikiPushService, services: true do ...@@ -198,7 +198,7 @@ RSpec.describe Git::WikiPushService, services: true do
context 'when a page we do not know about has been deleted' do context 'when a page we do not know about has been deleted' do
def run_service def run_service
wiki_page = create(:wiki_page, wiki: wiki) wiki_page = create(:wiki_page, wiki: wiki)
process_changes { delete_page(wiki_page.page.path) } process_changes { delete_page(wiki_page.page) }
end end
it 'create a new meta-data record' do it 'create a new meta-data record' do
...@@ -350,8 +350,8 @@ RSpec.describe Git::WikiPushService, services: true do ...@@ -350,8 +350,8 @@ RSpec.describe Git::WikiPushService, services: true do
git_wiki.update_page(page.path, title, 'markdown', 'Hey', commit_details) git_wiki.update_page(page.path, title, 'markdown', 'Hey', commit_details)
end end
def delete_page(path) def delete_page(page)
git_wiki.delete_page(path, commit_details) wiki.delete_page(page, 'commit message')
end end
def commit_details def commit_details
......
...@@ -469,7 +469,6 @@ RSpec.shared_examples 'wiki model' do ...@@ -469,7 +469,6 @@ RSpec.shared_examples 'wiki model' do
end end
describe '#delete_page' do describe '#delete_page' do
shared_examples 'delete_page operations' do
let(:page) { create(:wiki_page, wiki: wiki) } let(:page) { create(:wiki_page, wiki: wiki) }
it 'deletes the page' do it 'deletes the page' do
...@@ -493,9 +492,6 @@ RSpec.shared_examples 'wiki model' do ...@@ -493,9 +492,6 @@ RSpec.shared_examples 'wiki model' do
subject.delete_page(page) subject.delete_page(page)
end end
end
it_behaves_like 'delete_page operations'
context 'when an error is raised' do context 'when an error is raised' do
it 'logs the error and returns false' do it 'logs the error and returns false' do
...@@ -509,14 +505,6 @@ RSpec.shared_examples 'wiki model' do ...@@ -509,14 +505,6 @@ RSpec.shared_examples 'wiki model' do
expect(subject.delete_page(page)).to be_falsey expect(subject.delete_page(page)).to be_falsey
end end
end end
context 'when feature flag :gitaly_replace_wiki_delete_page is disabled' do
before do
stub_feature_flags(gitaly_replace_wiki_delete_page: false)
end
it_behaves_like 'delete_page operations'
end
end end
describe '#ensure_repository' do describe '#ensure_repository' do
......
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