Add redirect to rename commit (#1648)

This PR ensures that changes to `REDIRECTS_FILE` are committed with the commit responsible for the corresponding git rename.
This commit is contained in:
Nikita Ivanov
2021-01-08 18:36:54 +05:00
committed by GitHub
parent 18a16665cc
commit 333af9b76c
+3 -2
View File
@@ -303,12 +303,13 @@ module Precious
redirect to("/#{page.escaped_url_path}")
return
end
committer.commit
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
# Add a redirect from the old page to the new
wiki.add_redirect(page.url_path, clean_url(new_path)) if @redirects_enabled
wiki.add_redirect(page.url_path, clean_url(new_path), commit) if @redirects_enabled
committer.commit
page = wiki_page(new_path).page
return if page.nil?