Home > Back-end >  enforce file casing via pre-commit hook
enforce file casing via pre-commit hook

Time:04-05

I would like to enforce lower-case – and possibly snake_case – file names throughout a git repo, ideally via a pre-commit hook. Alas, Google comes up empty for this particular use case; check-case-conflict isn't quite what I'm looking for. Does any such thing exist?

CodePudding user response:

the easiest way to do this is via a language: fail hook

something like this:

repos:
-   repo: local
    hooks:
    -   id: lower-case-only
        name: lower case only
        entry: filenames must be lower-case or lower_case only
        language: fail
        files: '[^a-z0-9._/-]'

disclaimer: I wrote pre-commit

  • Related