Skip to content

Commit fd81e06

Browse files
authored
Merge pull request #55 from rios0rios0/feat/changelog
feat(changelog): added the feature to automatically fix incorrect section heading levels
2 parents f8a4f8c + ea84443 commit fd81e06

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Exceptions are acceptable depending on the circumstances (critical bug fixes tha
1616

1717
## [Unreleased]
1818

19+
### Added
20+
21+
- added the feature to automatically fix incorrect section heading levels
22+
1923
## [2.13.0] - 2024-02-13
2024

2125
### Added

cmd/autobump/changelog.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ func updateSection(
182182
unreleasedSection []string,
183183
nextVersion semver.Version,
184184
) ([]string, *semver.Version, error) {
185+
// Fix incorrect section heading levels
186+
re := regexp.MustCompile(`(?i)^\s*#+\s*(Added|Changed|Deprecated|Removed|Fixed|Security)`)
187+
for i, line := range unreleasedSection {
188+
if re.MatchString(line) {
189+
correctedLine := "### " + strings.TrimSpace(strings.Replace(line, "#", "", -1))
190+
unreleasedSection[i] = correctedLine
191+
}
192+
}
193+
185194
var newSection []string
186195
var currentSection *[]string
187196
sections := map[string]*[]string{
@@ -264,5 +273,9 @@ func updateSection(
264273
}
265274
}
266275

276+
if majorChanges == 0 && minorChanges == 0 && patchChanges == 0 {
277+
return nil, nil, fmt.Errorf("no changes found in the unreleased section")
278+
}
279+
267280
return newSection, &nextVersion, nil
268281
}

0 commit comments

Comments
 (0)