Skip to content

Commit

Permalink
Fixed an issue with adding [undefined] to the generated changelog (#…
Browse files Browse the repository at this point in the history
…660)

* Fix generated undefined in changelog

* fix: update test snapshot

* Create tame-guests-fold.md

* Include the fix in the `@changesets/changelog-git` too

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
tmkx and Andarist committed Nov 8, 2021
1 parent 74dda8c commit 5413f3e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-guests-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Fixed an issue with adding `[undefined]` to the generated changelog when the commit adding a changeset file could not be found. This could have happened when running `changeset add && changeset version` in a single command and when using the default changelog generator.
8 changes: 4 additions & 4 deletions packages/apply-release-plan/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ describe("apply release plan", () => {
### Patch Changes
- Hey, let's have fun with testing!
- Updated dependencies [undefined]
- Updated dependencies
- pkg-b@1.2.1`);

expect(readmeB.trim()).toEqual(outdent`# pkg-b
Expand All @@ -1621,7 +1621,7 @@ describe("apply release plan", () => {
### Patch Changes
- Hey, let's have fun with testing!
- Updated dependencies [undefined]
- Updated dependencies
- pkg-a@1.0.4`);
});

Expand Down Expand Up @@ -1791,7 +1791,7 @@ describe("apply release plan", () => {
### Patch Changes
- Hey, let's have fun with testing!
- Updated dependencies [undefined]
- Updated dependencies
- pkg-c@2.1.0`);

expect(readmeC.trim()).toEqual(outdent`# pkg-c
Expand Down Expand Up @@ -1890,7 +1890,7 @@ describe("apply release plan", () => {
### Patch Changes
- Hey, let's have fun with testing!
- Updated dependencies [undefined]
- Updated dependencies
- pkg-c@2.0.1`);

expect(readmeC.trim()).toEqual(outdent`# pkg-c
Expand Down
5 changes: 4 additions & 1 deletion packages/changelog-git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const getDependencyReleaseLine = async (
if (dependenciesUpdated.length === 0) return "";

const changesetLinks = changesets.map(
changeset => `- Updated dependencies [${changeset.commit}]`
changeset =>
`- Updated dependencies${
changeset.commit ? ` [${changeset.commit}]` : ""
}`
);

const updatedDepenenciesList = dependenciesUpdated.map(
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {

const getReleaseLine = async (
changeset: NewChangesetWithCommit,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type: VersionType
_type: VersionType
) => {
const [firstLine, ...futureLines] = changeset.summary
.split("\n")
Expand All @@ -32,7 +31,10 @@ const getDependencyReleaseLine = async (
if (dependenciesUpdated.length === 0) return "";

const changesetLinks = changesets.map(
changeset => `- Updated dependencies [${changeset.commit}]`
changeset =>
`- Updated dependencies${
changeset.commit ? ` [${changeset.commit}]` : ""
}`
);

const updatedDepenenciesList = dependenciesUpdated.map(
Expand Down

0 comments on commit 5413f3e

Please sign in to comment.