Skip to main content

Formatter Helper for your commit message

Project description

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/).*'
        ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prepare_commit_msg-0.0.1.zip (11.3 kB view details)

Uploaded Source

File details

Details for the file prepare_commit_msg-0.0.1.zip.

File metadata

  • Download URL: prepare_commit_msg-0.0.1.zip
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for prepare_commit_msg-0.0.1.zip
Algorithm Hash digest
SHA256 c1e58ca66da9bdc9cb964113026d36d48f3b16e7be1f4693eded6eb36ea26633
MD5 8bbe813201ad8990e73a4e25ca055685
BLAKE2b-256 3d221f2dae893882be719285bc35a8c0c6183e60f273b4208135fb446b67b178

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page