Skip to content

Prek identifies a file named makefile.png as a text makefile #2087

@akx

Description

@akx

Summary

Naming a .png file makefile.png (however misguided that is, but just so happened in a production environment) should not make it text. 😄

$ wget https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png
2026-05-15 15:23:46 (445 MB/s) - ‘Example.png’ saved [2335/2335]
$ file Example.png
Example.png: PNG image data, 172 x 178, 8-bit colormap, non-interlaced
$ prek util identify Example.png
Example.png: binary, file, image, non-executable, png
$ mv Example.png makefile.png
$ prek util identify makefile.png
makefile.png: binary, file, image, makefile, non-executable, png, text

Then pre-commit-hooks like end-of-file-fixer and trailing-whitespace will happily corrupt the PNG (as it's identified as text):

$ prek run --all-files
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

  Fixing makefile.png
trim trailing whitespace.................................................Passed

Willing to submit a PR?

  • Yes — I’m willing to open a PR to fix this.
    • I left this blank, as I'm not sure what a good fix is. Making binary and text mutually exclusive for identify? Is that compatible with upstream pre-commit?

Platform

Darwin 24.6.0 arm64 (but shouldn't matter)

Version

prek 0.4.0 (b570c73 2026-05-14)

.pre-commit-config.yaml

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions