Skip to content

Commit

Permalink
Fix version heads map pre_commit rule (#33749)
Browse files Browse the repository at this point in the history
Only run it when the map may have changed (migration or core version
change), and also only check migration files (ignore things like
pycache).
  • Loading branch information
jedcunningham authored Aug 26, 2023
1 parent 3ba994d commit a746def
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ repos:
language: python
entry: ./scripts/ci/pre_commit/pre_commit_version_heads_map.py
pass_filenames: false
files: ^airflow/migrations/versions|^airflow/__init__.py$
additional_dependencies: ['packaging','google-re2']
- id: update-version
name: Update version to the latest version in the documentation
Expand Down
3 changes: 3 additions & 0 deletions scripts/ci/pre_commit/pre_commit_version_heads_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def sorting_key(filen):
sorted_filenames = sorted(filenames, key=sorting_key)

for filename in sorted_filenames:
if not filename.endswith(".py"):
print(f"skipping non-migration file: {filename}")
continue
with open(os.path.join(MIGRATION_PATH, filename)) as file:
content = file.read()
revision_match = re2.search(pattern, content)
Expand Down

0 comments on commit a746def

Please sign in to comment.