meel-ayush opened a new pull request, #76372:
URL: https://github.com/apache/airflow/pull/76372

   ### Description
   
   This PR addresses an existing TODO in 
`scripts/ci/prek/check_supervisor_schemas_versions.py`:
   > `TODO: We should consolidate the common logic with 
check_execution_api_versions.py into common_prek_utils`
   
   Both `check_execution_api_versions.py` and 
`check_supervisor_schemas_versions.py` duplicated identical routines for target 
branch resolution, file diffing, and temporary git worktree lifecycle 
management. In addition, both scripts allocated temporary directories using 
`tempfile.mkdtemp()`. While the inner worktree was removed on exit, the 
enclosing temporary folder remained uncleaned, leaking orphaned directories in 
the temporary filesystem across runs.
   
   - Centralized target branch discovery (`get_target_branch`), file diffing 
(`get_changed_files`), and worktree lifecycle management into 
`scripts/ci/prek/common_prek_utils.py`.
   - Introduced `temporary_target_branch_worktree()` as a context manager using 
`tempfile.TemporaryDirectory()`, ensuring complete cleanup of both the worktree 
and parent temporary directory on normal exit or exception.
   - Refactored `check_execution_api_versions.py` and 
`check_supervisor_schemas_versions.py` to use the shared helper and removed the 
committer TODO.
   
   ### Tests
   
   - Added unit tests in `scripts/tests/ci/prek/test_common_prek_utils.py` 
covering worktree creation, error recovery cleanup, and branch resolution edge 
cases.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [ ] Yes (please specify the tool below)


-- 
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]

  • [PR] Consolidate target branc... meel-ayush (via GitHub) via commits

Reply via email to