airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Add a precommit to detect when docs have been moved

Open amoghrajesh opened this issue 1 year ago • 7 comments

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.

amoghrajesh avatar Apr 22 '25 16:04 amoghrajesh

Saw this here today: https://github.com/apache/airflow/pull/49539

amoghrajesh avatar Apr 22 '25 16:04 amoghrajesh

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?

insomnes avatar Apr 23 '25 08:04 insomnes

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.

amoghrajesh avatar May 08 '25 06:05 amoghrajesh

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.

insomnes avatar May 12 '25 07:05 insomnes

Thanks! Take care

amoghrajesh avatar May 12 '25 09:05 amoghrajesh

@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.

potiuk avatar Mar 02 '26 19:03 potiuk

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.

waseem1302-x avatar Nov 23 '26 17:11 waseem1302-x