Skip to content

Commit

Permalink
Add UpdateReleaseNotes util
Browse files Browse the repository at this point in the history
  • Loading branch information
derekblank committed Oct 12, 2023
1 parent d64997c commit e00416d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cli/pkg/utils/change_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ import (
"regexp"
)

// Updates the release notes by replacing "Unreleased" with
// the new version and adding a new "Unreleased" section
func UpdateReleaseNotes(version, path string) error {
return readWriteNotes(version, path, releaseNotesUpdater)
}

// See UpdateReleaseNotes
// This handles the string replacement
func releaseNotesUpdater(version string, notes []byte) []byte {
re := regexp.MustCompile(`(^Unreleased\s*\n)`)

repl := fmt.Sprintf("$1---\n\n%s\n", version)

return re.ReplaceAll(notes, []byte(repl))
}

// Updates the change log by replacing "Unreleased" with
// the new version and adding a new "Unreleased" section
func UpdateChangeLog(version, path string) error {
Expand Down

0 comments on commit e00416d

Please sign in to comment.