feat: less repetitive entries for for prerelease changelogs (#37)

Right now we always show all new releasable commits since the last
_stable_ release.

If a project publishes multiple pre-releases in a row, they all repeat
the same lines with a few new additions.

On the other hand, when we cut a stable release, we do want to show all
changes since the last stable release, as we can not expect users to
read the changelog of pre-releases.

As a compromise, the code now looks at the type of release that is being
created, and decides based on that if we will look at STABLE..HEAD
(stable release) or LATEST..HEAD (pre-release).

Close #33
This commit is contained in:
Julian Tölle 2024-08-30 19:44:51 +02:00 committed by GitHub
parent 693ca21e32
commit 971b6e6ef7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View file

@ -61,7 +61,6 @@ func NewReleasePullRequest(head, branch, version, changelogEntry string) (*Relea
type ReleaseOverrides struct {
Prefix string
Suffix string
// TODO: Doing the changelog for normal releases after previews requires to know about this while fetching the commits
NextVersionType NextVersionType
}
@ -92,6 +91,17 @@ func (n NextVersionType) String() string {
}
}
func (n NextVersionType) IsPrerelease() bool {
switch n {
case NextVersionTypeRC, NextVersionTypeBeta, NextVersionTypeAlpha:
return true
case NextVersionTypeUndefined, NextVersionTypeNormal:
return false
default:
return false
}
}
// Label is the string identifier of a pull/merge request label on the forge.
type Label string

View file

@ -178,7 +178,15 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
logger.InfoContext(ctx, "no latest tag found")
}
releasableCommits, err := rp.forge.CommitsSince(ctx, releases.Stable)
// By default, we want to show everything that has happened since the last stable release
lastReleaseCommit := releases.Stable
if releaseOverrides.NextVersionType.IsPrerelease() {
// if the new release will be a prerelease,
// only show changes since the latest release (stable or prerelease)
lastReleaseCommit = releases.Latest
}
releasableCommits, err := rp.forge.CommitsSince(ctx, lastReleaseCommit)
if err != nil {
return err
}