Skip to content

Commit

Permalink
Merge pull request #74 from thc202/fix/changelog-newline
Browse files Browse the repository at this point in the history
Normalize number of newlines on changelog update
  • Loading branch information
psiinon committed Jun 10, 2024
2 parents 3d993c6 + cf8d3d0 commit 2e8fd11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Normalize the number of newlines when updating the changelog.

## [0.10.0] - 2023-12-01
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static boolean isVersionStart(String line) {
}

private String addChange(StringBuilder versionContents) {
String normalisedChange = change.get().replaceAll("\r\n?", "\n") + '\n';
String normalisedChange = change.get().replaceAll("\r?\n", "\n") + '\n';
if (!isDuplicate()) {
String contents = versionContents.toString();
if (contents.contains(normalisedChange)) {
Expand All @@ -212,7 +212,7 @@ private String addChange(StringBuilder versionContents) {
}
versionContents.insert(insertPosition, normalisedChange);

return versionContents.toString();
return versionContents.toString().trim() + "\n\n";
}

private boolean isDuplicate() {
Expand Down

0 comments on commit 2e8fd11

Please sign in to comment.