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

version bump with breaking change, release candidate (rc0) didn't increment major version number #472

Open
jon-nfc opened this issue Jan 16, 2022 · 7 comments

Comments

@jon-nfc
Copy link

jon-nfc commented Jan 16, 2022

Description

A breaking change was introduced in commit 5f273ce23a331eaf11623207ec4aba8b856c14f0. Current version was 0.3.0rc1 on the next version increment the version only incremented to 0.3.0 when it should have incremented to 1.0.0

repo link:

Git log with the commits in question including tags
$ git log
commit 389bc08d7686153fb374aa83d440c35c9b4eac90 (HEAD -> development, tag: v0.3.0)
Author: NFC CI <CI@nfc-gitlab>
Date:   Thu Aug 12 03:32:36 2021 +0000

    build(version): bump version 0.3.0rc1 → 0.3.0

commit f455eb2e278eb3fd7f9dde693587393ea2783cff
Merge: a629e39 3360a15
Author: Jon
Date:   Thu Aug 12 03:25:10 2021 +0000

    Merge branch 'style-readme' into 'development'
    
    style(readme): fix badge table.
    
    See merge request nofusscomputing/projects/gitlab-ci!7

commit 3360a15fde12682edfd9044d2541dc819615b838
Author: Jon
Date:   Thu Aug 12 12:47:23 2021 +0930

    fix(commit_message): fixed commit message check if there is only one commit to the branch
    
    !7

commit 2c61651d9c08f4cf364e45768e07f3ece34ec8c0
Author: Jon
Date:   Thu Aug 12 12:45:31 2021 +0930

    style(readme): fix formatting of badge table
    
    The badge table did not render on github,
    adjuested so that each row is on one line for github markdown to function
    
    !7

commit a629e39f59d865a6c2e86627d0a62146de0ea7ca
Merge: f4ee55d 0653766
Author: Jon
Date:   Wed Aug 11 06:37:28 2021 +0000

    Merge branch 'update-readme' into 'development'
    
    docs(readme): added how to use repo
    
    See merge request nofusscomputing/projects/gitlab-ci!5

commit 0653766c935cb117082bfe1481ae83e4a1b2bb5c
Author: Jon
Date:   Wed Aug 11 15:52:28 2021 +0930

    docs(readme): Updated badges and intro
    
    !5

commit d61056243804728e059b99fce1644a8cc37230bb
Author: Jon
Date:   Wed Aug 11 14:17:29 2021 +0930

    feat(python_linting): added ci job, python linting, code quality and scoring
    
    Added a job to lint python files and ouput a code quality report for gitlab MR.
    
    A html report is also available within the artifacts. if the badge is used,
    the badge links to the html code quality report.
    
     Changes to be committed:
            modified:   .gitlab-ci.yml
            new file:   python/.gitlab-ci.yml
            new file:   python/README.md
            new file:   python/requirements.txt
    
    issue #1

commit def31ef562c0002713401652657d59320548ee85
Author: Jon
Date:   Wed Aug 11 13:47:34 2021 +0930

    style(yaml_lint): fixed yaml lint errors
    
    yaml lint was producing linting errors. Amended affected lines.
    
    #1

commit d20a56fa0ca492e3fc2ad7c548fc891cc8ffc8ec
Author: Jon
Date:   Wed Aug 11 13:14:36 2021 +0930

    feat(yaml_lint): Added job yaml lint for checking yaml files
    
    defaults to checking subfolder/.gitlab-ci.yml.
    
     Changes to be committed:
            modified:   .gitlab-ci.yml
            new file:   yaml_lint/.gitlab-ci.yml
            new file:   yaml_lint/.yamllint.yaml
            new file:   yaml_lint/README.md
            new file:   yaml_lint/requirements.txt
    
    issue #1

commit 9f7a24c1ebc0bdb5a153977dcb1c53d7ec2fb140
Author: Jon
Date:   Wed Aug 11 12:44:22 2021 +0930

    docs(gitlab_templates): added issue and merge request templates
    
    #1

commit da8eb5c3381379f6e405c3ebe14d9a883c52f41a
Author: Jon
Date:   Wed Aug 11 12:41:51 2021 +0930

    docs(template): added template readme for CI job folders
    
    #1

commit ace7a03456861d59e2f904405f45409c53e831ab
Author: Jon
Date:   Wed Aug 11 12:40:30 2021 +0930

    docs(readme): explain sync and using github to link gitlab-ci
    
    !5 #1

commit 8790917e7d959aa7b8305912bb443ba6b72200c6
Author: Jon
Date:   Wed Aug 11 12:30:30 2021 +0930

    docs(readme): explain repo layout and versioning
    
    !5

commit 19900945e763249b6ef7a9e2e2cbcf11748b1eea
Author: Jon
Date:   Wed Aug 11 12:26:18 2021 +0930

    docs(readme): added how to update gitlab-ci
    
    !5

commit 63af1efb4fd92a9f8755f766728a18d8f390b805
Author: Jon
Date:   Wed Aug 11 12:14:50 2021 +0930

    fix(commit_footer_refs): Use the current git branch for comparison.
    
    dynamically select the current branch so that it can be compared to the dev branch
    
    !5 #1

commit 8a988ebf09015211f8f6566acc0ba71c1f00bee1
Author: Jon
Date:   Wed Aug 11 12:07:56 2021 +0930

    docs(readme): Added how to use this repository
    
    !5

commit f4ee55daa58cb2b9bb494a2955956cd3af5861fb
Merge: d929c1d dc13d4f
Author: Jon
Date:   Sun Aug 8 06:35:41 2021 +0000

    Merge branch 'changelog-footer-toggle' into 'development'
    
    feat(changelog): be able to switch changelog references inclusion.
    
    See merge request nofusscomputing/projects/gitlab-ci!4

commit dc13d4f2841038c085dcf29dfb0b0c5d2f00f099
Author: Jon
Date:   Sun Aug 8 15:43:28 2021 +0930

    docs(gitlab_release): Added user docs to fix errors from ci job 'commit footer refs'
    
    User documentation provided as it is linked from the junit test report in the gitlab interface.
    
    closes #3 closes #4

commit 22136f7dd22b9487d362a7ed63ca1b76e52b9cc7
Author: Jon
Date:   Sun Aug 8 15:28:00 2021 +0930

    feat(gitlab_release): Toggle var added to enable switching changelog references.
    
    using var 'CHANGELOG_FOOTER_REFERENCES' set to False when generating a changelog
    with 'cz' will not add the commit footer refrences to the changelog.
    
    issue #3

commit eb0bf4c1740dbd7a47ceb031c0d1c854899a1e40
Author: Jon
Date:   Sun Aug 8 15:15:06 2021 +0930

    refactor(gitlab_release): file link to be in local repository for helping fix commit footer ref check failures
    
    issue #4

commit 81776223c5cb392c12c7ca63488a1df10290e9d1
Author: Jon
Date:   Sun Aug 8 15:04:06 2021 +0930

    refactor(gitlab_release): use a name for failed test to denote the issue
    
    issue #4

commit 756b9406dde8cf0bf0030ac72855a054ece3a883
Author: Jon
Date:   Sun Aug 8 14:58:36 2021 +0930

    feat(gitlab_release): be able to toggle commit footer check job
    
    if var CHANGELOG_FOOTER_REFERENCES=False, dont conduct validation job.
    
    issue #4

commit 7cb676eb98a7de30d47a6b49a87067116684cfd2
Author: Jon
Date:   Sun Aug 8 14:51:57 2021 +0930

    ci(gitlab_release): Add a validation job to check if commit messages contain a gitlab reference in the footer
    
    #4

commit 11e156619d0d820e534897bafd5f39e6f9defcbf
Author: Jon
Date:   Sun Aug 8 14:50:34 2021 +0930

    feat(gitlab_release): python module to check if a commit message has gitlab references in the footer
    
    #4

commit d2d4ac0afa123eb161916735b999b470a30e273e
Author: Jon
Date:   Sun Aug 8 14:47:49 2021 +0930

    build(.gitignore): ignore python build files
    
    !4

commit d929c1d3b01fe68764029e6a6a13a620871ad1b4
Merge: cc2f23b 35edb7c
Author: Jon
Date:   Sat Aug 7 07:53:17 2021 +0000

    Merge branch 'changelog-footer' into 'development'
    
    feat(changelog): Add commit footer to Changelog
    
    See merge request nofusscomputing/projects/gitlab-ci!3

commit 35edb7cfc59e2d147bdb5cb5d03710ec747073ae
Author: Jon
Date:   Sat Aug 7 17:14:48 2021 +0930

    docs(changelog): Updated changelog to new layout
    
    Changelog now adds issue and merge request references from the commit footer line.
    
    !3 #3

commit 8699c41219d70e6f41f42dc7f2c1bcf542b3f723
Author: Jon
Date:   Sat Aug 7 16:14:10 2021 +0930

    feat(gitlab_release): Add commit footer to changelog
    
    !1 #3

commit cc2f23b091925659c03196b69456f4033b460294
Merge: eb5cc8a 5f273ce
Author: Jon
Date:   Sat Aug 7 05:31:59 2021 +0000

    Merge branch 'fix-releases' into 'development'
    
    fix(gitlab_releases): version increment workflow from RC-release -> full-release
    
    See merge request nofusscomputing/projects/gitlab-ci!2

commit 5f273ce23a331eaf11623207ec4aba8b856c14f0
Author: Jon
Date:   Sat Aug 7 14:56:51 2021 +0930

    docs(gitlab_release): Updated docs with new instructions on version incrementing
    
    BREAKING CHANGE: !2

commit f76cabeeb04b028a231dc1c232862db5fcad4345
Author: Jon
Date:   Sat Aug 7 13:56:25 2021 +0930

    fix(gitlab_release): Adjust release workflow
    
    Previous release workflow only allowed version increment of RC on development brnach.
    
    adjust to the following workflow:
        master branch: automatically increment the version
        development branch: option to manually increment version (RC increment only)
    
    !2

commit eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31 (tag: v0.3.0rc1)
Author: NFC CI <CI@nfc-gitlab>
Date:   Wed Aug 4 03:23:08 2021 +0000

    build(version): bump version 0.3.0rc0 → 0.3.0rc1

Steps to reproduce

  1. git clone https://gitlab.com/nofusscomputing/projects/gitlab-ci.git

  2. git checkout development

  3. git fetch --tags

  4. delete all tags after tag v0.3.0rc1

  5. git reset f455eb2e278eb3fd7f9dde693587393ea2783cff --hard

  6. run commands to bump version

$ git reset f455eb2e278eb3fd7f9dde693587393ea2783cff --hard
HEAD is now at f455eb2 Merge branch 'style-readme' into 'development'

(dev_env) i$ cz -n cz_nfc bump --prerelease rc --dry-run
build(version): bump version 0.3.0rc1 → 0.3.0rc2
tag to create: v0.3.0rc2
increment detected: None

(dev_env) $ cz -n cz_nfc bump --dry-run
build(version): bump version 0.3.0rc1 → 0.3.0
tag to create: v0.3.0
increment detected: MINOR

(dev_env) $ 

Adding a commit with a ! after the type still fails

(dev_env) $ git log -2
commit 83ac9e6a88c3ba6bf4c93153f46acce10dcceb69 (HEAD -> development)
Author: Jon
Date:   Sun Jan 16 12:15:46 2022 +0930

    buid(test)!: Test breaking change
    
    text for body goes here
    
    the commit footer

commit f455eb2e278eb3fd7f9dde693587393ea2783cff
Merge: a629e39 3360a15
Author: Jon 
Date:   Thu Aug 12 03:25:10 2021 +0000

    Merge branch 'style-readme' into 'development'
    
    style(readme): fix badge table.
    
    See merge request nofusscomputing/projects/gitlab-ci!7
(dev_env) $ cz -n cz_nfc bump --dry-run
build(version): bump version 0.3.0rc1 → 0.3.0
tag to create: v0.3.0
increment detected: MINOR

(dev_env) $ cz -n cz_nfc bump --prerelease rc --dry-run
build(version): bump version 0.3.0rc1 → 0.3.0rc2
tag to create: v0.3.0rc2
increment detected: None

(dev_env) $ 

Current behavior

Does not do a MAJOR version increment when breaking change introduced.

Desired behavior

breaking change, should always increment the MAJOR version number regardless of current version.

Environment

  • cz version: commitizen version: (test machine 2.17.13) however CI uses current as of date of job. Also tested with cz-0.0.0.0.dev20200924 CI Build Log

  • Custom Module cz_nfc (this is the version at the time of the failed version bump) however even the Current cz_nfc module does not make a difference

$ python --version
Python 3.6.9

python3 -c "import platform; print(platform.system())"

  • test machine:

    $ python -c "import platform; print(platform.system())"
    Linux
    
  • CI Build Log #1497464492

  • operating system: Linux (Gitlab CI: Linux gitlab runner using docker image python 3.6)

cz version --report

$ cz version --report
usage: cz [-h] [--debug] [-n NAME]
          {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}
          ...
cz: error: unrecognized arguments: --report
(dev_env) $ 

I have reviewed the docs to ensure that I haven't done anything wrong. However to no avail.

@Lee-W
Copy link
Member

Lee-W commented Jan 17, 2022

Hi @jon-nfc , thanks for reporting. I've confirmed it. This might relate to #415 and #454 what we've not yet had the time to dig into it.

@jon-nfc
Copy link
Author

jon-nfc commented Jan 17, 2022

Hi @jon-nfc , thanks for reporting. I've confirmed it. This might relate to #415 and #454 what we've not yet had the time to dig into it.

@Lee-W, thank you for taking the time to review.

I don't believe it's related to #415 as this issue pertains to bumping when there is no commits with a type that would bump the version. As seen in my commit history above, I had more than enough commits to bump the version. However in my case a major version bump never occurred.

As for #454 i again do not see this as related, as my changelog is working as intended.

My issue is, TLDR. Current version was a rc, a breaking change commit was added. However the version bump was not a major version bump, it was an rc to a non rc bump (0.3.0rc1 -> 0.3.0 should have been 0.3.0rc1 -> 1.0.0). A breaking change, regardless of version should ALWAYS bump the major version number.

@Lee-W
Copy link
Member

Lee-W commented Jan 18, 2022

If that's the case, I think we might need more time to dig into this issue. My guess is that it might be related to semver_generator. Thanks for your report and detailed description!

@jon-nfc
Copy link
Author

jon-nfc commented Jan 18, 2022

That does look like it is the place that prevents the increment after reviewing sem ver 1.0.0 it is clear when a MAJOR bump should occur as a breaking change is supposed to do.

I think this patch to https://github.com/commitizen-tools/commitizen/blob/master/commitizen/bump.py#L78-L98 maybe what is required. However am not aware of how the prefix is added, so this patch maybe incomplete.

+    # regardless of release prefix, if any. 
+    # A BREAKING CHANGE must increment MAJOR version
+    # Example: 0.5.0rc1 -> 1.0.0rc1 for prerelease
+    # Example: 0.5.0rc1 -> 1.0.0 for non-prerelease
+    if increment == MAJOR:
+        increments_version[MAJOR] += 1
+        increments_version[MINOR] = 0
+        increments_version[PATCH] = 0
+
    # This flag means that current version
    # must remove its prerelease tag,
+    # before a PATCH/MINOR increment
-    # so it doesn't matter the increment.
    # Example: 1.0.0a0 with PATCH/MINOR -> 1.0.0
-    if not version.is_prerelease:
+    if not version.is_prerelease && increment != MAJOR:

-        if increment == MAJOR:
-            increments_version[MAJOR] += 1
-            increments_version[MINOR] = 0
-            increments_version[PATCH] = 0
-        elif increment == MINOR:
+        if increment == MINOR:
            increments_version[MINOR] += 1
            increments_version[PATCH] = 0
        elif increment == PATCH:
            increments_version[PATCH] += 1

    return str(
        f"{increments_version['MAJOR']}."
        f"{increments_version['MINOR']}."
        f"{increments_version['PATCH']}"
    )

A patch is also required to the increment detection, as per my command output above the increment detected for the version bump was minor, not major. so there also appears to be a bug within this logic too.

The above would enable a workflow of (example):

  • current release 0.5.0rc1

  • work is done, non-breaking change and version bump, version increment to 0.5.0rc2

  • now if a breaking change is commited, version bump, version increment 0.5.0rc2 -> 1.0.0rc1 for prerelease and 0.5.0rc2 -> 1.0.0 if non-prerelease

@jenstroeger
Copy link
Contributor

In this context please be careful with the --major-version-zero flag.

@woile
Copy link
Member

woile commented Apr 28, 2023

Is this issue still happening? Could you check against commitizen v3? thanks

@jon-nfc
Copy link
Author

jon-nfc commented Jun 13, 2023

@woile,

applogies for the tardy reply. no i wont be testing and wasting my time when the logic is still the same however with different line numbers

# This flag means that current version
# must remove its prerelease tag,
# so it doesn't matter the increment.
# Example: 1.0.0a0 with PATCH/MINOR -> 1.0.0
if not version.is_prerelease:
if increment == MAJOR:
increments_version[MAJOR] += 1
increments_version[MINOR] = 0
increments_version[PATCH] = 0
elif increment == MINOR:
increments_version[MINOR] += 1
increments_version[PATCH] = 0
elif increment == PATCH:
increments_version[PATCH] += 1
return str(
f"{increments_version['MAJOR']}."
f"{increments_version['MINOR']}."
f"{increments_version['PATCH']}"
)

REF: #472 (comment)

@Lee-W Lee-W removed the discussion label Jun 23, 2023
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

4 participants