Skip to main content

commitizen with kpn style

Project description

KPN'S COMMITIZEN

PyPI Package latest release PyPI Package download count (per month) Docker Image Version (latest by date)

Example commit

About

Plugin for python's commitizen, which uses KPN commit rules to bump versions, update files and generate changelogs.

KPN Rules summary

Schema

<PREFIX> <SUBJECT> (#<ISSUE_ID>)

<LONG_DESCRIPTION>
Prefix SemVer relation Description
FIX PATCH Backwards compatible change that fixes something
OPT PATCH Other changes like refactors, docs, which are backwards compatible
NEW MINOR New functionality
BREAK MAJOR Breaking changes

Example

NEW: Add login screen (#MY-123)

MORE INFO

Custom configuration

This rules support custom configuration. You can set the following options in your pyproject.toml file:

[tool.commitizen]
# ...
kpn_strict_check = true
kpn_commit_url = "https://github.com/kpn/cz-kpn/commit/$COMMIT_REV"
  • kpn_strict_check: Enable strict mode during cz check and cz commit.
  • kpn_commit_url: URL to the commit page on your version control system. Which will be used to generate the changelog.

Installation

Install globally in your system

python -m pip install --user cz-kpn

Or add cz-kpn to your project:

poetry add cz-kpn --group dev

Quickstart

Initialize cz-kpn in your project

Answer the questions appearing in:

cz init

Bumping and changelog

Just run:

cz bump

Committing

cz commit

or the shortcut

cz c

With docker

cmd="cz -n cz_kpn commit"
docker run --rm -it -v $(pwd):/app kpnnl/cz-kpn:5.0.0 $cmd

Features

Client tool to assist in the creation of a commit

Example commit]

note: gif is outdated

This command is useful for newcomers, or when you don't remember the meaning of each change type. It will display a prompt which will guide the user in the commit creation.

cz commit
git cz commit

Automatic version bump

Automatic version bump with changelog generation.

cz bump --changelog

Note: The --changelog flag is not required if update_changelog_on_bump = true

Example bump

Automatic changelog generation

If you don't want to generate a tag and bump the version, run:

cz changelog

This will create a changelog with unreleased commits, alternatively, you can run

cz changelog --incremental

to add only the missing changes. This is useful if you have manually modified your changelog.

Validate commit message

This command will tell you if there are any valid or invalid commit messages in the given range.

You can also add it to .pre-commit hooks or manually as a git hook.

More info in commitizen website.

cz check --rev-range ugnu348hg84hg84g..j8fj84g84h84hg83h2392

You can also check against the last version:

cz check --rev-range "$(cz version -p).."

Configuration

The recommendation is to run cz init which will help you create the right configuration and file.

You can also add manually to your pyproject.toml or create a .cz.toml file with:

[tool.commitizen]
name = "cz_kpn"
version = "<YOUR_CURRENT_VERSION>"
version_files = [
  "src/__version__.py"
]

Help

cz --help

Contents:

$ cz --help
usage: cz [-h] [--config CONFIG] [--debug] [-n NAME] [-nr NO_RAISE]
          {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} ...

Commitizen is a powerful release management tool that helps teams maintain consistent and meaningful commit messages while automating version management.
For more information, please visit https://commitizen-tools.github.io/commitizen

options:
  -h, --help            show this help message and exit
  --config CONFIG       the path of configuration file
  --debug               use debug mode
  -n NAME, --name NAME  use the given commitizen (default: cz_conventional_commits)
  -nr NO_RAISE, --no-raise NO_RAISE
                        comma separated error codes that won't raise error, e.g: cz -nr 1,2,3 bump. See codes at
                        https://commitizen-tools.github.io/commitizen/exit_codes/

commands:
  {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
    init                init commitizen configuration
    commit (c)          create new commit
    ls                  show available commitizens
    example             show commit example
    info                show information about the cz
    schema              show commit schema
    bump                bump semantic version based on the git log
    changelog (ch)      generate changelog (note that it will overwrite existing file)
    check               validates that a commit message matches the commitizen schema
    version             get the version of the installed commitizen or the current project (default: installed commitizen)

Testing

For details about supported Python versions and local testing instructions, see PYTHON_TESTING.md.

Contributing

Read Contributing guide

Using in a github action

name: Bump version and generate changelog

on:
  push:
    branches:
      - main

jobs:
  bump-version:
    if: ${{ !startsWith(github.event.head_commit.message, 'BUMP:') }}
    runs-on: ubuntu-latest
    name: "Bump version and create changelog with commitizen"
    steps:
      - name: Check out
        uses: actions/checkout@v5
        with:
          fetch-depth: 0
          token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
      - name: Create bump and changelog
        uses: commitizen-tools/commitizen-action@master
        id: cz
        with:
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
          changelog_increment_filename: body.md
          extra_requirements: "cz-kpn"
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          body_path: "body.md"
          tag_name: ${{ steps.cz.outputs.version }}  # Or use env.REVISION
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The secrets.PERSONAL_ACCESS_TOKEN is required in order to trigger other actions observing the tag creation. An alternative is to use workflow_call to trigger the workflow from the current workflow.

Read more in commitizen docs

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

cz_kpn-5.0.0.tar.gz (808.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cz_kpn-5.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file cz_kpn-5.0.0.tar.gz.

File metadata

  • Download URL: cz_kpn-5.0.0.tar.gz
  • Upload date:
  • Size: 808.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cz_kpn-5.0.0.tar.gz
Algorithm Hash digest
SHA256 b5d3e5564f7a416510b16c8518f55238293e348e4a44385e9d39d56c2a00a6a2
MD5 e3ae37498b51f70a8ea4e0b46449f829
BLAKE2b-256 144d90c99e95e69a65a573689705d76c583d01936f73827b66cca77768e64ebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cz_kpn-5.0.0.tar.gz:

Publisher: release.yaml on kpn/cz-kpn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cz_kpn-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: cz_kpn-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cz_kpn-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df77329ff88b02e425eacf507793087e72da0869b1ea4e8871c40e1cb55321cc
MD5 54fbbf3f4991a631b893ab650588a32d
BLAKE2b-256 99b855cbf0c6db337a1af48431dd05e5d75f9e24187d29372340cc8473e8fd98

See more details on using hashes here.

Provenance

The following attestation bundles were made for cz_kpn-5.0.0-py3-none-any.whl:

Publisher: release.yaml on kpn/cz-kpn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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