From 333af9b76cfebb942713ee9392f14cfe0bbe726e Mon Sep 17 00:00:00 2001 From: Nikita Ivanov <51688199+ViChyavIn@users.noreply.github.com> Date: Fri, 8 Jan 2021 18:36:54 +0500 Subject: [PATCH] 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. --- lib/gollum/app.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 2f645b64..f6e98a5c 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -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?