Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09c2648

Browse files
authored
Merge pull request #19697 from meeseeksmachine/auto-backport-of-pr-19690-on-v3.4.x
Backport PR #19690 on branch v3.4.x (Only warn about existing redirects if content differs.)
2 parents 736ac0c + 4c7db09 commit 09c2648

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

doc/sphinxext/redirect_from.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ def _generate_redirects(app, exception):
7676
return
7777
for k, v in RedirectFrom.redirects.items():
7878
p = Path(app.outdir, k + builder.out_suffix)
79+
html = HTML_TEMPLATE.format(v=v)
7980
if p.is_file():
80-
logger.warning(f'A redirect-from directive is trying to create '
81-
f'{p}, but that file already exists (perhaps '
82-
f'you need to run "make clean")')
81+
if p.read_text() != html:
82+
logger.warning(f'A redirect-from directive is trying to '
83+
f'create {p}, but that file already exists '
84+
f'(perhaps you need to run "make clean")')
8385
else:
86+
logger.info(f'making refresh html file: {k} redirect to {v}')
8487
p.parent.mkdir(parents=True, exist_ok=True)
85-
with p.open("x") as file:
86-
logger.info(f'making refresh html file: {k} redirect to {v}')
87-
file.write(HTML_TEMPLATE.format(v=v))
88+
p.write_text(html)

0 commit comments

Comments
 (0)