Skip to content

Commit 709d99c

Browse files
committed
fix: end changelog version entry with empty line
Append an empty line to the changelog entry when writing it to the changelog file, to ensure there's an empty line above the next version entry. Fixes #63 Signed-off-by: Matthew Weier O'Phinney <[email protected]>
1 parent d949667 commit 709d99c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Changelog/ChangelogReleaseNotes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use RuntimeException;
1010
use Webmozart\Assert\Assert;
1111

12+
use function rtrim;
13+
1214
/**
1315
* @psalm-immutable
1416
*/
@@ -33,10 +35,12 @@ public static function writeChangelogFile(string $changelogFile, self $releaseNo
3335

3436
Assert::notNull($releaseNotes->changelogEntry);
3537

38+
$changelogEntry = rtrim($releaseNotes->contents, "\n") . "\n\n";
39+
3640
$editor = new ChangelogEditor();
3741
$editor->update(
3842
$changelogFile,
39-
$releaseNotes->contents,
43+
$changelogEntry,
4044
$releaseNotes->changelogEntry
4145
);
4246
}

test/unit/Changelog/ChangelogReleaseNotesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testWriteChangelogRewritesFileWithNewContents(): void
9898
$contents = file_get_contents($filename);
9999

100100
$this->assertStringContainsString($requiredString, $contents);
101-
$this->assertStringContainsString($releaseNotes->contents(), $contents);
101+
$this->assertStringContainsString($releaseNotes->contents() . "\n", $contents);
102102
}
103103

104104
public function testMergeRaisesExceptionIfBothCurrentAndNextInstanceContainChangelogEntries(): void

0 commit comments

Comments
 (0)