Skip to content

pre-commit hook: make sure your package doesn't refer to different versions of itself across the codebase ✅

License

Notifications You must be signed in to change notification settings

jalvaradosegura/version-checker

Repository files navigation

version-checker

black isort License image-by


Documentation: https://jalvaradosegura.github.io/version-checker/

Tutorial from scratch: https://dev.to/jalvaradosegura/dont-forget-to-update-that-value-in-those-files-3i78


Requirements

Quickstart

Create a .pre-commit-config.yaml file (like any other pre-commit hook):

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/jalvaradosegura/version-checker
    rev: v0.5.0-alpha
    hooks:
      - id: version-checker
        args: [--files, CHANGELOG.md, Jenkinsfile, testing_hooks/__init__.py]

With this configuration we are saying: before each commit, check that the files defined after --files, contains the version indicated in the pyproject.toml file.

You can make the hook look up for the version in another file. This is done by setting the --grab-version-from argument in the .yaml file.

How it looks when running it

Following the previous example, let's say that I updated the version of a package I'm working on to 3.0.0 in the pyproject.toml file. Then I updated almost all references to that version on the different files, but I forgot to do it on the CHANGELOG.md file:

Example

If we then update the CHANGELOG.md file accordingly, the hook will pass.

Remember that you can always set the stages parameter in your .pre-commit-config.yaml, to make it run, for example, only before doing a push.

About

pre-commit hook: make sure your package doesn't refer to different versions of itself across the codebase ✅

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages