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

Provide a way to override the behavior of major commit messages for pre-1.0.0 versions #204

Closed
dalewking opened this issue Oct 11, 2024 · 4 comments

Comments

@dalewking
Copy link

In order to promote the convention of using major: My message for breaking changes, before 1.0.0 a major in a commit message will be read as minor.

I understand the reasoning for that but, that puts me in a catch-22 that I have no good way to promote a library to 1.0.0 status. The docs say that:

The goal is to promote you explicitly documenting breaking changes in your commit logs, while requiring the actual 1.0.0 version bump to come via an override with -Preckon.scope=major.

But that assumes that the developer is releasing and pushing things to the repo directly. In good development practice pushing directly to a main branch is forbidden and the only way to change main is via pull requests that are built in a CI/CD build.

The question then is how can one then through a pull request move the library to 1.0.0? The only way I can see is to do a PR that forces scope to major, merge it, do another PR that undoes the forcing of scope and merge that. That is not a good developer experience. There should be an option to disable the pre-1.0.0 behavior or perhaps set a minimum version

@dalewking
Copy link
Author

My workaround for now:

    // This is a workaround for this issue: https://github.com/ajoberstar/reckon/issues/204
    // It can be removed after 1.0.0 is released
    fun forceMajorReleaseFromPreRelease(forceRelease: Boolean) =
        ScopeCalculator { inventory ->
            Optional.ofNullable(
                Scope.MAJOR.takeIf {
                    forceRelease && inventory.baseNormal < Version.valueOf("1.0.0")
                }
            )
        }

    setScopeCalc(
        forceMajorReleaseFromPreRelease(true)
            .or(calcScopeFromCommitMessages()),
    )

@dalewking
Copy link
Author

The way I see this working would be an optional parameter to calcScopeFromCommitMessages that specifies whether to allow commit messages to upgrade to 1.0.0

ajoberstar added a commit that referenced this issue Nov 24, 2024
As reported in #204, I had unfortunately forced the preference to not
allow commit messages to bump to v1 on all users of commit message
scope calculators. In theory, I had meant to allow custom parsing, but
the custom parsing still enforced the pre-1.0 special casing.

The new approach implements a new ofCommitMessageParser() mechanism
that has the parsing function accept both the commit message and a
boolean indicating whether the project is pre-v1.0.0. This allows the
user full control of the approach they want to use.

To simplify adoption of this new capability the default commit message
parser was enhanced to allow "major!: subject" prefixes that bypass
the pre-1.0.0 check, allowing a more CD style bump to 1.0.0.

Fixes #204
@ajoberstar
Copy link
Owner

Planning to release soon and you'll have two options:

  • Use the existing calcScopeFromCommitMessages() which now allows a major!: My message prefix to force a 1.0.0 bump
  • Use calcScopeFromCommitMessageParser(...) with a custom parser of the form (String commitMessage, boolean preV1) -> Optional<Scope>

@dalewking
Copy link
Author

dalewking commented Nov 24, 2024 via email

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