Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumping issue with PATCH version #871

Closed
Lavish-jain-5 opened this issue Sep 27, 2023 · 2 comments
Closed

Bumping issue with PATCH version #871

Lavish-jain-5 opened this issue Sep 27, 2023 · 2 comments

Comments

@Lavish-jain-5
Copy link

Description

While using commitizen, if we have any non-eligible bump commits, like if we defined custom bump map. In which if I defined style or docs as non-eligible bumping commits. So when I did any non-bumping commits after that If I do PATCH version bumping commits. It's not bumping the version. It just bumps when any MAJOR or MINOR version is present.

Steps to reproduce

  1. Define
    bump_pattern = r"^(break|fix|feat|docs|style|refactor|perf|test)((.+))?(:.*)"
    bump_map = {"break": "MAJOR", "feat": "MINOR", "fix": "PATCH", "refactor": "PATCH", "perf": "PATCH"}

  2. Then do any non-eligible bumping commits like (docs, style, test) commit.

  3. After that do any PATCH version commit like (fix, perf)

Current behavior

So while doing PATCH commits after any non-eligible commits. It's not bumping the PATCH version. We need to do any MAJOR or MINOR commit to bump the version.

Desired behavior

It should Bump the version if we have any PATCH commit in stack with any non-eligible commits.

Screenshots

No response

Environment

ubuntu wsl

@Lavish-jain-5 Lavish-jain-5 changed the title Good bug title tells us about precise symptom, not about the root cause. Bumping issue with PATCH version Sep 27, 2023
@Lavish-jain-5
Copy link
Author

So we can solve this issue by adding one condition in find_increment function in commitizen.bump file.


def patched_find_increment(commits, regex: str, increments_map) -> str:
    if isinstance(increments_map, dict):
        increments_map = OrderedDict(increments_map)

    # Most important cases are major and minor.
    # Everything else will be considered patch.
    select_pattern = re.compile(regex)
    increment = None
    for commit in commits:
        for message in commit.message.split("\n"):
            result = select_pattern.search(message)
            if result:
                found_keyword = result.group(1)
                new_increment = None
                for match_pattern in increments_map.keys():
                    if re.match(match_pattern, found_keyword):
                        new_increment = increments_map[match_pattern]
                        break

                if increment == MAJOR:
                    break
                elif increment == MINOR and new_increment == MAJOR:
                    increment = new_increment
                elif increment == PATCH and new_increment is None:
                    increment = increment
                elif increment == PATCH or increment is None:
                    increment = new_increment

    return increment

@Lee-W
Copy link
Member

Lee-W commented May 20, 2024

Hi @Lavish-jain-5, thanks for reporting this issue. I just tested it with the latest version (3.26.0) without encountering this issue. Could you please update the commitizen and see whether the issue still persists? I'm going to close this one, but let me know if the issue is still there 🙂

@Lee-W Lee-W closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants