Skip to content

Commit 0386937

Browse files
authored
fix: Add optional to type chain (#560)
* Add optional to type chain * Add tests
1 parent 395a38c commit 0386937

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/utils/__tests__/changelog.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('generateChangesetFromGit', () => {
290290
pr?: {
291291
local?: string;
292292
remote?: {
293-
author: { login: string };
293+
author?: { login: string };
294294
number: string;
295295
body?: string;
296296
milestone?: string;
@@ -389,6 +389,19 @@ describe('generateChangesetFromGit', () => {
389389
{},
390390
'### Various fixes & improvements\n\n- Upgraded the kernel (#123) by @sentry',
391391
],
392+
[
393+
'Does not error when PR author is null',
394+
[
395+
{
396+
hash: 'abcdef1234567890',
397+
title: 'Upgraded the kernel',
398+
body: '',
399+
pr: { remote: { number: '123' } },
400+
},
401+
],
402+
{},
403+
'### Various fixes & improvements\n\n- Upgraded the kernel (#123)',
404+
],
392405
[
393406
'handle multiple commits properly',
394407
[

src/utils/changelog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ interface CommitInfo {
380380
nodes: Array<{
381381
number: string;
382382
body: string;
383-
author: {
383+
author?: {
384384
login: string;
385385
};
386386
milestone: {
@@ -472,7 +472,7 @@ async function getPRAndMilestoneFromCommit(
472472
hash.slice(1),
473473
pr
474474
? {
475-
author: pr.author.login,
475+
author: pr.author?.login,
476476
pr: pr.number,
477477
prBody: pr.body,
478478
milestone: pr.milestone?.number ?? null,

0 commit comments

Comments
 (0)