Skip to content

Commit

Permalink
Merge "[IMPR] show the current redirect target with redirect summary"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jul 21, 2024
2 parents d0bcad4 + ca7cd28 commit 8f79a7e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)}')
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8f79a7e

Please sign in to comment.