Skip to content

Automagically prefix and format commit messages when committing

License

Notifications You must be signed in to change notification settings

boidolr/pre-commit-msg

Repository files navigation

pre-commit-msg tag python Build pre-commit

A collection of prepare message and commit message git hooks for use with the pre-commit framework. For details see the list of available hooks below.

Using pre-commit-msg with pre-commit

Add this to your .pre-commit-config.yaml:

    -   repo: https://github.com/boidolr/pre-commit-msg
        rev: v1.3.2  # Use the ref you want to point at
        hooks:
        -   id: format-message
        # -   id: ...

For an extended example see .pre-commit-config.yaml.

Available hooks

  • prepare-message: Change commit messages to include a prefix.
    • --ignore-branch will lead to the branch not being checked.
    • --pattern can be used to change the feature branch pattern to take the message prefix from. Needs to match with --prefix-pattern. Defaults to feature/(\w+-\d+).
    • --prefix-pattern should match the prefix of the message to normalize it. Needs to match with --pattern. Defaults to ^\s*\w+-\d+\s*:
  • format-message: Ensure commit message conforms to format of headline followed by two empty lines.
    • --capitalize if the subject line should be capitalized. Other lines remain unchanged.