Add a precommit to detect when docs have been moved
Body
This is useful when we move over / rename docs and miss adding those in redirects.txt leading to trouble later for external links.
Adding a precommit will catch hold of a good chunk of those.
Committer
- [x] I acknowledge that I am a maintainer/committer of the Apache Airflow project.
Saw this here today: https://github.com/apache/airflow/pull/49539
I would be happy to work on this one, if possible. But could you clarify a bit, please:
The main idea here is to detect moved / renamed rst files on pre-commit hook and check if the move was reflected in the corresponding redirects.txt file.
If not, add the redirection to the end of the file. Or it should just fail in this case?
Hello @insomnes apologies for delayed response, just catching up now.
The main idea here is to detect moved / renamed rst files on pre-commit hook and check if the move was reflected in the corresponding redirects.txt file.
Precisely.
If not, add the redirection to the end of the file. Or it should just fail in this case?
I think we can start with failing and if its easy enough during implementation, add it too. I just worry that it could be error-prone to add it.
Thanks for the clarification! No problem with the delay. I've been really sick for the last 3 weeks, so I will only be able to continue on this one closer to the end of the week.
I just worry that it could be error-prone to add it.
My initial PoC research showed it could be fragile, yes. I will start by renaming detection and failing, and see where it goes.
Thanks! Take care
@insomnes We are unassigning you from this issue as part of our updated assignment policy.
This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.
We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.
Hi, I'm working on this.
I reproduced the gap first: renaming a doc file without updating redirects.txt is not caught by any existing hook. A staged rename shows up in git's own rename detection, but nothing flags the missing redirect entry, so the old URL would break silently.
I'm implementing the fail-only hook discussed above: fail the commit when the old path is missing from the owning docs tree's redirects.txt, no auto-add. I'll open a draft PR once the hook and its tests are verified locally.