Skip to content

Commit e8ffc35

Browse files
committed
return undefined if empty
1 parent c4e7957 commit e8ffc35

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

dist/index.js

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const FIXES_REGEX = /^CHANGELOG-FIXES:(.*)/gm
77
const ADDS_REGEX = /^CHANGELOG-ADDS:(.*)/gm
88

99
export interface Changelog {
10-
added: string[]
11-
fixed: string[]
10+
added: string[] | undefined
11+
fixed: string[] | undefined
1212
}
1313

1414
interface ReleaseInfo {
@@ -42,22 +42,21 @@ export async function generateChangelog(
4242
let lastReleaseVersion
4343
for (const release of releases) {
4444
// Only consider releases of the same type as the current channel.
45-
if (release.name.startsWith(channel)) {
45+
if (
46+
release.name.startsWith(channel) &&
47+
!release.version.startsWith(
48+
currentVersion.substring(0, currentVersion.length - 1 - 2)
49+
)
50+
) {
51+
// Check for a release where `release.version` is less then `currentVersion`, which means `localCompare` would return `1`.
4652
if (
47-
!release.version.startsWith(
48-
currentVersion.substring(0, currentVersion.length - 1 - 2)
49-
)
53+
currentVersion.localeCompare(release.version, undefined, {
54+
numeric: true,
55+
sensitivity: 'base'
56+
}) === 1
5057
) {
51-
// Check for a release where `release.version` is less then `currentVersion`, which means `localCompare` would return `1`.
52-
if (
53-
currentVersion.localeCompare(release.version, undefined, {
54-
numeric: true,
55-
sensitivity: 'base'
56-
}) === 1
57-
) {
58-
lastReleaseVersion = release.version
59-
break
60-
}
58+
lastReleaseVersion = release.version
59+
break
6160
}
6261
}
6362
}
@@ -187,7 +186,7 @@ function parseChangelogFromPrDescriptions(prDescriptions: string[]): Changelog {
187186
}
188187

189188
return {
190-
added: changelog_new,
191-
fixed: changelog_fixed
189+
added: changelog_new || undefined,
190+
fixed: changelog_fixed || undefined
192191
}
193192
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function run(): Promise<void> {
1616
channel
1717
)
1818

19-
core.setOutput('changelog', JSON.stringify(changelog))
19+
core.setOutput('changelog', changelog)
2020
} catch (error) {
2121
if (error instanceof Error) core.setFailed(error.message)
2222
}

0 commit comments

Comments
 (0)