Skip to content

cz bump fails if pre-commit reformats CHANGELOG.md #502

Closed
@yajo

Description

@yajo

Description

When I use cz bump --changelog, it tries to commit the updated changelog, but fails because of pre-commit. Then I get stuck.

Steps to reproduce

  1. Add have a pre-commit config that applies prettier over markdown files.
  2. Configure it with 4 spaces.
  3. Add some changes that produce a bump.
  4. cz bump --changelog

Current behavior

> cz bump
bump: version 0.1.0 → 0.1.1
tag to create: v0.1.1
increment detected: PATCH

git.commit error: "prettier.................................................................Failed
- hook id: prettier
- files were modified by this hook

CHANGELOG.md"

> cz bump
Tag v0.1.1 could not be found. 
Possible causes:
- version in configuration is not the current version
- tag_format is missing, check them using 'git tag --list'

? Is this the first tag created? No
[NO_COMMITS_FOUND]
No new commits found.

Desired behavior

It should do at least 2 commit attempts, just in case the 1st one fails due to a pre-commit hook.

Otherwise, it should revert version bump diff, to let me fix the changelog manually and issue cz bump again.

Screenshots

No response

Environment

Commitizen Version: 2.24.0
Python Version: 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)]
Operating System: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions