jorisroovers / gitlint

Linting for your git commit messages
http://jorisroovers.github.io/gitlint
MIT License
787 stars 99 forks source link

Feature request: Support for `pre-commit` env variables #548

Open tsuoanttila opened 1 month ago

tsuoanttila commented 1 month ago

pre-commit sets some environment variables when you run it with --from-ref foo --to-ref bar that could hopefully be easily picked up and used same as --commits foo..bar. This would make it quite easy to validate every commit in a pre-commit based CI workflow.

For example, when running pre-commit run --from-ref=main --to-ref=HEAD the following env vars are set:

    "PRE_COMMIT_ORIGIN": "main",
    "PRE_COMMIT_SOURCE": "HEAD",
    "PRE_COMMIT_FROM_REF": "main",
    "PRE_COMMIT_TO_REF": "HEAD",
    "PRE_COMMIT": "1",

If you think this is a good idea, but don't have the time, I'll try to make a PR for you Soon™️.