Jotta E
Jotta E

Reputation: 302

Configure commitizen to bump a default version


Can we configure commitizen command

cz bump

to bump to a default version (i.e. PATCH ) if there is no commit bump_pattern (i.e. ^(break|new|fix|hotfixi)) in the commit message?

This is the part in my .cz.yaml that controls the bumping behavior:

  bump_map:
  break: MAJOR
  fix: PATCH
  hotfix: PATCH
  new: MINOR
  "": PATCH
  bump_pattern: ^(break|new|fix|hotfix|.*)

after saving the file and running 'cz bump' I see that the .cz.yaml file was updated to:

  bump_map:
  ? ''
  : PATCH
  break: MAJOR
  fix: PATCH
  hotfix: PATCH
  new: MINOR

I know that my regex isn't correct but even if updating it, how do I configure the 'bump_map' to assign PATCH on every commit that doesn't start with a type:? Thanks

Upvotes: 1

Views: 1114

Answers (1)

Ours
Ours

Reputation: 111

I had the same issue and here is the way I solved this: In the pyproject.toml (I am using poetry) add those line

[tool.commitizen]
name = "cz_customize"

[tool.commitizen.customize]
bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH", " " = "PATCH"}

in commitizen yaml configuration file it should be something like this:

commitizen:
  name: cz_customize
  customize:
    bump_map:
      break: MAJOR
      fix: PATCH
      hotfix: PATCH
      new: MINOR
      " ": PATCH

You were almost there but it seems that you don't need to modify the "bump_pattern"

Upvotes: 0

Related Questions