Skip to main content

prepare-commit-msg

Yet another tool for the prepare-commit-msg git hook. To use with pre-commit

For pre-commit: see https://github.com/pre-commit/pre-commit

What's all about

In many projects some sort of ticket system is used. The commit messages are used for updating the status of the ticket by "linking" the ticket name, which it is nothing more than mentioning the ticket name, in the commit message.

This allows for using a jinja2 template for formatting your commit message.

You can configure this with the following commandline options:

  • -t / --template - absolute path to the template. Default value: name of bundled template: prepare_commit_msg_append.j2 file
  • -b / --branch - may be specified multiple times to exclude branches from formatting the commit message. Default values: main, master
  • -p / --pattern - may be specified multiple times to include branches for formatting the commit message. Default value: (?<=feature/).*

Usage

# .pre-commit-config.yaml file
default_install_hook_types:
  - pre-commit
  - prepare-commit-msg
repos:
  - repo: https://github.com/davidmpaz/prepare-commit-msg
    rev: v0.0.1
    hooks:
      - id: prepare-commit-msg
        name: Prepare Commit Message
        description: Add statistics and a message template to the commit message.
        stages: [ prepare-commit-msg ]
        args: [
          -t, prepare_commit_msg_prepend.j2,
          -b, main, -b, master, -b, test, -b develop,
          -p, '(?<=feature/).*', -p, '(?<=release/).*'
        ]

or if having the package installed via pip:

# .pre-commit-config.yaml file
default_install_hook_types:
  - pre-commit
  - prepare-commit-msg
repos:
  - repo: local
    hooks:
      - id: prepare-commit-msg
        name: Prepare Commit Message
        description: Add statistics and a message template to the commit message.
        stages: [ prepare-commit-msg ]
        entry: prepare-commit-msg
        args: [
          -t, prepare_commit_msg_prepend.j2,
          -b, main, -b, master, -b, test, -b develop,
          -p, '(?<=feature/).*', -p, '(?<=release/).*'
        ]

Release files for prepare-commit-msg 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prepare-commit-msg 0.0.1
File Size Uploaded
prepare_commit_msg-0.0.1.zip 11.3 kB Details

Release files / prepare_commit_msg-0.0.1.zip

Download URL prepare_commit_msg-0.0.1.zip
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c1e58ca66da9bdc9cb964113026d36d48f3b16e7be1f4693eded6eb36ea26633
BLAKE2b-256 checksum
How to use checksums
3d221f2dae893882be719285bc35a8c0c6183e60f273b4208135fb446b67b178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.9

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page