waseem1302-x opened a new pull request, #77499: URL: https://github.com/apache/airflow/pull/77499
closes: #49565 This adds a pre-commit hook that fails when a renamed `.rst` doc file has no entry in the owning docs tree's `redirects.txt`, so a moved page stops breaking its old URL silently. The hook is fail-only: it reports the missing redirect and exits 1. It does not auto-add entries, per the discussion on the issue. How it works: - Rename detection uses git's own rename detection (`git diff --name-status -M`), not heuristics. - The range comes from `PRE_COMMIT_FROM_REF` / `PRE_COMMIT_TO_REF` as a two-dot diff, falling back to `--cached` at commit time. The push workflow in `basic-tests.yml` now passes that range in its `--files` and `--all-files` branches, so the hook runs in CI for every new commit of a push. - Redirect matching uses the final matching entry per source (last line wins, mirroring the Sphinx redirect generator). Inline comments are stripped before parsing, and tab-separated entries stay invalid, matching the real parser. - It fails closed: git, rev-parse, diff, and `git show` failures return 1. A missing `redirects.txt` still reports "Missing redirect" for the move. - A filename with a space gets a specific diagnostic, since spaced names cannot be represented in `redirects.txt`. Tests: 28 new tests, all passing. The same 28 fail on main without the change. Full `scripts/` suite: 2157 passed, 5 skipped, with only the 3 pre-existing `test_local_yml_mounts.py` breeze failures (they fail on main too). `prek validate-config` passes. Known limitations: - When the push base cannot be fetched, the workflow can only check the last commit's renames; an earlier-commit rename in that rare fallback is still missed. - A heavily rewritten move that git classifies as add+delete rather than a rename is not caught. - The hook checks that the old-path entry exists with a non-empty target; it does not verify the target resolves to the new page. --- ##### Was generative AI tooling used to co-author this PR? - [ ] Yes (please specify the tool below) --- * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged. * For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed. * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
