@@ -3,7 +3,7 @@ import shell from 'shelljs'
3
3
4
4
// Regexes to find the changelog contents within a PR.
5
5
const FIXES_REGEX = / ^ C H A N G E L O G - F I X E S : ( .* ) / gm
6
- const ADDS_REGEX = / ^ C H A N G E L O G - A D D S : ( .* ) / gm
6
+ const NEW_REGEX = / ^ C H A N G E L O G - N E W : ( .* ) / gm
7
7
8
8
export interface Changelog {
9
9
added : string [ ] | undefined
@@ -48,8 +48,9 @@ export async function generateChangelog(
48
48
)
49
49
) {
50
50
// Check for a release where `release.version` is less then `currentVersion`, which means `localCompare` would return `1`.
51
+ // This is by no means a perfect check, but should suffice because each version is of the exact same format and length.
51
52
if (
52
- currentVersion . localeCompare ( release . version , undefined , {
53
+ currentVersion . localeCompare ( release . version , undefined /* locales */ , {
53
54
numeric : true ,
54
55
sensitivity : 'base'
55
56
} ) === 1
@@ -65,6 +66,7 @@ export async function generateChangelog(
65
66
const currentBranch = branchFromVersion ( currentVersion , channel )
66
67
const previousBranch = branchFromVersion ( lastReleaseVersion , channel )
67
68
69
+ // Find all the commits that are in `currentBranch` but not `previousBranch`.
68
70
const command = shell . exec (
69
71
`git --no-pager log ^${ previousBranch } ${ currentBranch } --pretty=format:%H` ,
70
72
{ silent : true }
@@ -83,6 +85,8 @@ export async function generateChangelog(
83
85
}
84
86
}
85
87
88
+ // Returns the release branch from a version tag. A version like `v0.2022.04.11.09.09.stable_01` would
89
+ // be converted to `stable_release/v0.2022.04.11.09.09.stable`.
86
90
function branchFromVersion ( version : string , channel : string ) : string {
87
91
return `origin/${ channel } _release/${ version . substring (
88
92
0 ,
@@ -177,7 +181,7 @@ function parseChangelogFromPrDescriptions(prDescriptions: string[]): Changelog {
177
181
}
178
182
}
179
183
180
- const addMatches = prDescription . matchAll ( ADDS_REGEX )
184
+ const addMatches = prDescription . matchAll ( NEW_REGEX )
181
185
if ( addMatches ) {
182
186
const addMatchesArray = [ ...addMatches ]
183
187
for ( const addMatch of addMatchesArray ) {
0 commit comments