Skip to content

Allow sorting file contents on windows machines#1257

Closed
TomsCodingCode wants to merge 1 commit into
pre-commit:mainfrom
TomsCodingCode:main
Closed

Allow sorting file contents on windows machines#1257
TomsCodingCode wants to merge 1 commit into
pre-commit:mainfrom
TomsCodingCode:main

Conversation

@TomsCodingCode
Copy link
Copy Markdown

I ran into this issue, because in one of our CI/CD pipeline's we run the pre-commit checks on a windows image, which would result in a puzzling output from the file_contents_sorter hook.

Before the hook would perform a .rstrip(b'\n\r') on all lines, removing the CR character, and then join the lines together, only using '\n', resulting in white space differences that are hard to spot.

With this PR the newline sequence of the first line is used to determine how to strip and join the lines before and after sorting.

Added unit tests to ensure consistent behaviour on windows.

@asottile
Copy link
Copy Markdown
Member

asottile commented Jun 1, 2026

this feature has been declined already. you can read the discussion and recommendations if you search the issue tracker for it

@asottile asottile closed this Jun 1, 2026
@pre-commit pre-commit locked as resolved and limited conversation to collaborators Jun 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants