Skip to content

Conversation

@pankajkoti
Copy link
Member

Following up with PR #38717, this PR adds a pre-commit hook
to keep the tags list sorted in the OpenAPI spec yaml.

I previously tried to use the pyyaml library, to find the tags
and rewrite sorted tags, but upon rewrite it does not maintain
the original order of components in the YAML thus creating
huge changes for the PR to review. Hence, taking a simple
approach to read the file line by line, find the indexes of the
start entry and end entry of the tags list, sort those specific lines
and rewrite the lines with the sorted list of tags.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@pankajkoti
Copy link
Member Author

pankajkoti commented Apr 7, 2024

Pre-commit in action:

The file contents that were manually updated to check the pre-commit:
Screenshot 2024-04-07 at 2 23 49 PM

Pre-commit failed while trying to commit the modified files
Screenshot 2024-04-07 at 2 32 29 PM

Pre-commit sorted the tags and updated the file to:
Screenshot 2024-04-07 at 2 26 13 PM

Pre-commit success
Screenshot 2024-04-07 at 2 32 52 PM

@pankajkoti pankajkoti requested a review from kaxil April 7, 2024 09:05
@pankajkoti pankajkoti force-pushed the add-precommit-sort-openapi-tags branch from 1555864 to 45e46a9 Compare April 7, 2024 09:09
@potiuk
Copy link
Member

potiuk commented Apr 7, 2024

Yeah. Sometimes parsers are not the best in preserving thigns and old-good file reading + regexp is best.

@potiuk potiuk merged commit 9fcc1e8 into apache:main Apr 7, 2024
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants