Apply every rename when updating links between renamed files - #1792
Open
eastagiletracker wants to merge 1 commit into
Open
Apply every rename when updating links between renamed files#1792eastagiletracker wants to merge 1 commit into
eastagiletracker wants to merge 1 commit into
Conversation
update_links_between_renamed_files rebuilt each replacement from the pristine file content, so only the last rename in the list survived. A pull request that moves two or more pages that link to each other left a link to an old path behind, which the manage-renames workflow then auto-committed and mkdocs build --strict rejected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes a one-line fix to
.config/update_rename_links.pyso that links between renamed pages are rewritten for every rename in a pull request instead of only the last one. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/282. You can sign in with your GitHub ID to claim ownership of the project.What goes wrong
update_links_between_renamed_files()seedsnew_contentfrom the file it is fixing and then loops over the renames, but each pass recomputes the replacement from the pristinecontentrather than from the running result:Every pass discards the previous one, so at most one rename is ever reflected in a given page — whichever happens to come last. When a pull request moves two or more pages that link to each other, the pages whose target is not last keep links to paths that no longer exist. Because
.github/workflows/manage-renames.ymlruns this script on every pull request and auto-commits the result, those stale links land on the contributor's branch, andmkdocs build --strictthen rejects the branch the script was supposed to repair.The neighbouring helper
update_renamed_file_links()already accumulates correctly withnew_content = new_content.replace(...), which is what suggested this is a slip rather than a deliberate difference.Reproducing on master
At
f16dfc1onmaster, move two pages that link to each other into different subdirectories — the shape of a section reorganisation:Only one of the two pages is rewritten. The other still carries the link it had before the move, now pointing at nothing:
and the strict site build that
.config/mkdocs/mkdocs.shruns fails on exactly that link:The change, and how it was checked
The fix is to build on the running result, so each rename is applied on top of the last:
Since the repo has no test harness for these scripts, each check below is a command you can replay on this branch in a minute:
mkdocs build --stricton a cleanmasteratf16dfc1completes with no warnings, so anything new below is attributable to the change.../governance/guidebook-governance.mdand../contributing/editing-the-guidebook.md), and the same strict build completes with no warnings.incident-response-plan.md,incident-response-checklist.mdandincidents.mdinto a newincidents/directory: onmasterthe plan page keeps both of its links stale and is not even reported as updated; on this branch both are rewritten and resolve to files that exist.master's, and the script prints the same output — the change only affects the second and later renames, which are currently dropped.Nothing else in the file is touched, and no page content is changed by this PR.
How this was managed
This work was tracked on a board imported from this repository's own issues and pull requests — 1776 stories and 13 labels — with this fix as its own story on the board at https://eastagiletracker.com/projects/282.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com