Skip to content

Commit

Permalink
Merge pull request #1603 from intuit/released-plugin-bug
Browse files Browse the repository at this point in the history
fix parsing PR body when it's empty
  • Loading branch information
hipstersmoothie committed Oct 23, 2020
2 parents 9b60e1b + 77e7365 commit 0b42982
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions plugins/released/__tests__/released-label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,37 @@ describe("release label plugin", () => {
);
});

test("should work with a null PR body", async () => {
const releasedLabel = new ReleasedLabelPlugin();
const autoHooks = makeHooks();
releasedLabel.apply(({
hooks: autoHooks,
labels: defaultLabels,
logger: dummyLog(),
options: {},
comment,
git,
} as unknown) as Auto);

getPr.mockReturnValueOnce({ data: { body: null, head: { ref: "next" } } });
const commit = makeCommitFromMsg("normal commit with no bump (#123)");
await autoHooks.afterRelease.promise({
newVersion: "1.0.0",
lastRelease: "0.1.0",
commits: await log.normalizeCommits([commit]),
releaseNotes: "",
// @ts-ignore
response: mockResponse,
});

expect(comment).toHaveBeenCalledWith(
expect.objectContaining({
message:
":rocket: PR was released in [`v1.0.0`](https://git.hub/some/project/releases/v1.0.0) :rocket:",
})
);
});

test("should comment and label PRs with custom message", async () => {
const releasedLabel = new ReleasedLabelPlugin({
message:
Expand Down
2 changes: 1 addition & 1 deletion plugins/released/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class ReleasedLabelPlugin implements IPlugin {
releases,
});

pr.data.body.split("\n").map((line) => messages.push(line));
pr.data.body?.split("\n").map((line) => messages.push(line));

const commitsInPr = await auto.git!.getCommitsForPR(
commit.pullRequest.number
Expand Down

0 comments on commit 0b42982

Please sign in to comment.