Title: `file-contents-sorter` adds an extra blank line if the file to be sorted is empty · Issue #935 · pre-commit/pre-commit-hooks · GitHub
Open Graph Title: `file-contents-sorter` adds an extra blank line if the file to be sorted is empty · Issue #935 · pre-commit/pre-commit-hooks
X Title: `file-contents-sorter` adds an extra blank line if the file to be sorted is empty · Issue #935 · pre-commit/pre-commit-hooks
Description: I am on v.4.4.0, Python 3.11.4, macOS Ventura 13.4.1. My .pre-commit-config.yaml: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" hooks: - id: end-of-file-fixer - id: file-contents-sorter files: ^requirements\...
Open Graph Description: I am on v.4.4.0, Python 3.11.4, macOS Ventura 13.4.1. My .pre-commit-config.yaml: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" hooks: - id: end-of-file-fixer - id: fi...
X Description: I am on v.4.4.0, Python 3.11.4, macOS Ventura 13.4.1. My .pre-commit-config.yaml: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" hooks: - id: end-of-file-fixe...
Opengraph URL: https://github.com/pre-commit/pre-commit-hooks/issues/935
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`file-contents-sorter` adds an extra blank line if the file to be sorted is empty","articleBody":"I am on `v.4.4.0`, Python `3.11.4`, macOS Ventura `13.4.1`.\r\n\r\nMy `.pre-commit-config.yaml`:\r\n\r\n```yaml\r\nrepos:\r\n - repo: https://github.com/pre-commit/pre-commit-hooks\r\n rev: \"v4.4.0\"\r\n hooks:\r\n - id: end-of-file-fixer\r\n - id: file-contents-sorter\r\n files: ^requirements\\/.+\\.in$\r\n # args: [--unique, --ignore-case]\r\n```\r\n\r\nThe files are intentionally **empty** \u0026ndash; I'm in the planning stage, they are just placeholders for requriements[^1].\r\n\r\nTo the point: `file-contents-sorter` adds an extra blank to them, what results in a confict with `end-of-file-fixer`. I am not sure if that is the expected behavior... Updating `args` doesn't have any effect.\r\n\r\n```bash\r\n$ git:(install-and-configure-pre-commit) : pre-commit run --all-files\r\nfix end of files.........................................................Failed\r\n- hook id: end-of-file-fixer\r\n- exit code: 1\r\n- files were modified by this hook\r\n\r\nFixing requirements/build.in\r\nFixing requirements/lint.in\r\nFixing requirements/test.in\r\n\r\nfile contents sorter.....................................................Failed\r\n- hook id: file-contents-sorter\r\n- exit code: 1\r\n- files were modified by this hook\r\n\r\nSorting requirements/build.in\r\nSorting requirements/lint.in\r\nSorting requirements/test.in\r\n```\r\n\r\n[^1]: Yes, I know that I can use `requirements-txt-fixer` particularly for requirements. 😄 I will do. For that issue it doesn't matter.","author":{"url":"https://github.com/paduszyk","@type":"Person","name":"paduszyk"},"datePublished":"2023-07-20T10:45:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/935/pre-commit-hooks/issues/935"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:42ab09f5-2546-1de7-42a3-a6e6a632ce11 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9668:255A34:571698:7639BE:6A554308 |
| html-safe-nonce | 27b94507f22e0ffb4d8eaf3ab37fc9752b08e594a2e76ecede840cd351dbd633 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjY4OjI1NUEzNDo1NzE2OTg6NzYzOUJFOjZBNTU0MzA4IiwidmlzaXRvcl9pZCI6IjMwMjM5NDExNTQ2NzkxMTI0NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c0e6965c66802b64ef5a51f83dd781d0b63097d130376a929248fb321eb18943 |
| hovercard-subject-tag | issue:1813691162 |
| github-keyboard-shortcuts | repository,issues,commits,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit-hooks/935/issue_layout |
| twitter:image | https://opengraph.githubassets.com/587d21ca638c3542771a912b7b0b8cf37324daa86944e234dee781d0e75bcd2a/pre-commit/pre-commit-hooks/issues/935 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/587d21ca638c3542771a912b7b0b8cf37324daa86944e234dee781d0e75bcd2a/pre-commit/pre-commit-hooks/issues/935 |
| og:image:alt | I am on v.4.4.0, Python 3.11.4, macOS Ventura 13.4.1. My .pre-commit-config.yaml: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" hooks: - id: end-of-file-fixer - id: fi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | paduszyk |
| hostname | github.com |
| expected-hostname | github.com |
| None | cd9eea424140838b22e9eabd53d92b5702617ddd6d76efcd3a37f08d44309ca5 |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit-hooks git https://github.com/pre-commit/pre-commit-hooks.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17714713 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit-hooks |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17714713 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit-hooks |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3084b9f587e8f1e19803bbe0c77ac77ce3c99c5c |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width