From ca7cd284ff9a9159ac93917013e882725f1ac6ab Mon Sep 17 00:00:00 2001 From: xqt Date: Sun, 21 Jul 2024 17:27:17 +0200 Subject: [PATCH] [IMPR] show the current redirect target with redirect summary Bug: T254839 Change-Id: Ib56053e5885f3e76a30e4fa1698a18ecd2f76bd4 --- scripts/redirect.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/redirect.py b/scripts/redirect.py index c415c2dfde..faeca78b3b 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -529,7 +529,8 @@ def delete_1_broken_redirect(self) -> None: f'{redir_page} has been moved to {movedTarget}') reason = i18n.twtranslate( redir_page.site, 'redirect-fix-broken-moved', - {'to': movedTarget.title(as_link=True, + {'from': targetPage.title(allow_interwiki=False), + 'to': movedTarget.title(as_link=True, allow_interwiki=False)}, bot_prefix=True) content = redir_page.get(get_redirect=True) @@ -607,6 +608,7 @@ def fix_1_double_redirect(self) -> None: """Treat one double redirect.""" newRedir = redir = self.current_page redirList = [] # bookkeeping to detect loops + first_target = None while True: redirList.append( f'{newRedir.site.lang}:{newRedir.title(with_section=False)}') @@ -619,6 +621,7 @@ def fix_1_double_redirect(self) -> None: if not targetPage: break + first_target = first_target or targetPage pywikibot.info(f' Links to: {targetPage}.') mw_msg = None with suppress(KeyError): @@ -663,7 +666,9 @@ def fix_1_double_redirect(self) -> None: save=False) summary = i18n.twtranslate( redir.site, 'redirect-fix-double', - {'to': targetPage.title(as_link=True, allow_interwiki=False)}, + {'from': first_target.title(as_link=True, + allow_interwiki=False), + 'to': targetPage.title(as_link=True, allow_interwiki=False)}, bot_prefix=True) self.userPut(redir, oldText, redir.text, summary=summary, ignore_save_related_errors=True,