Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Newlines around section headers #324

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- Refactors the internal updater to more easily account for multiple entries and formatting ([#311](https://github.com/dangoslen/dependabot-changelog-helper/issues/311))
- ci: replace comment_tag with comment-tag ([#311](https://github.com/dangoslen/dependabot-changelog-helper/issues/318))
- Adds proper newlines around version and section headers ([#310](https://github.com/dangoslen/dependabot-changelog-helper/issues/310)). This will only add newlines if **adding** a new version and section. When adding a new entry, the newlines will not be added.

### Removed

Expand Down
46 changes: 45 additions & 1 deletion __tests__/changelog-updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,48 @@ test('adds an entry to the changelog when section exists under default unrelease
`)
})

const CHANGELOG_MISSING_VERSION = `# Changelog
`

test('adds an entry to the changelog adding the new version and section', async () => {
mockReadStream(CHANGELOG_MISSING_VERSION)

await runUpdate('UNRELEASED', './CHANGELOG.md', 'Bump', 'Dependencies')

expectWrittenChangelogToBe(`# Changelog

## [UNRELEASED]

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))
`)
})

const CHANGELOG_MISSING_VERSION_ONLY_HEADER = `# Changelog`

test('adds an entry to the changelog adding the new version and section when the only line is the header', async () => {
mockReadStream(CHANGELOG_MISSING_VERSION_ONLY_HEADER)

await runUpdate('UNRELEASED', './CHANGELOG.md', 'Bump', 'Dependencies')

expectWrittenChangelogToBe(`# Changelog

## [UNRELEASED]

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))
`)
})

const CHANGELOG_WITH_PROPER_SECTIONS_UNRELEASED = `# Changelog

## [UNRELEASED]
### Dependencies
`

test('adds an entry to the changelog when section already exists but no entries doe', async () => {
test('adds an entry to the changelog when section already exists but no entries do', async () => {
mockReadStream(CHANGELOG_WITH_PROPER_SECTIONS_UNRELEASED)

await runUpdate('v1.0.0', './CHANGELOG.md', 'Bump', 'Dependencies')
Expand Down Expand Up @@ -137,7 +172,9 @@ test('adds section and an entry to the changelog when version exists but section
expectWrittenChangelogToBe(`# Changelog

## [UNRELEASED]

### Changed

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))
`)
})
Expand Down Expand Up @@ -274,7 +311,9 @@ test('updates version with new section and entry', async () => {
## [v1.0.0]
### Added
### Removed

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))`
)
})
Expand Down Expand Up @@ -442,6 +481,7 @@ test('adds section when sections separated by blank lines', async () => {
- Removed a feature

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))

## [v0.9.0]
Expand Down Expand Up @@ -487,6 +527,7 @@ test('adds section when sections separated by blank lines contain nested entries
- Removed a feature

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))

## [v0.9.0]
Expand Down Expand Up @@ -627,7 +668,9 @@ test('add section and accounts for multi-line entry', async () => {
the goes
across
several lines

### Dependencies

- Update \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))
`)
})
Expand Down Expand Up @@ -708,6 +751,7 @@ test('adds section when sections separated by blank lines and adds multi package
- Removed a feature

### Dependencies

- Bump \`package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))
- Bump \`other-package\` from v1 to v2 ([#123](https://github.com/owner/repo/pull/123))

Expand Down
2 changes: 1 addition & 1 deletion coverage/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading