reckon icon indicating copy to clipboard operation
reckon copied to clipboard

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

Open dalewking opened this issue 1 year ago • 2 comments

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 avatar Oct 11 '24 19:10 dalewking

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 avatar Oct 11 '24 20:10 dalewking

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

dalewking avatar Oct 11 '24 20:10 dalewking

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>

ajoberstar avatar Nov 24 '24 01:11 ajoberstar

Thanks for changing this, though I have switched to https://github.com/jmongard/Git.SemVersioning.Gradle to get true conventional commits and changelog generation

On Sat, Nov 23, 2024, 8:58 PM Andrew Oberstar @.***> wrote:

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>

— Reply to this email directly, view it on GitHub https://github.com/ajoberstar/reckon/issues/204#issuecomment-2495749832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACUPTTLLH7I2ESJKG43I6D2CEXCXAVCNFSM6AAAAABPZPYDLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVG42DSOBTGI . You are receiving this because you authored the thread.Message ID: @.***>

dalewking avatar Nov 24 '24 15:11 dalewking