@@ -130,6 +130,28 @@ async function fetchPRDetails(prNumber) {
130130 }
131131}
132132
133+ function shouldIncludeInReleaseNotes ( prDescription ) {
134+ if ( ! prDescription ) return false ;
135+
136+ // Look for the inclusion marker
137+ const marker = 'Should this change be included in the release notes:' ;
138+ const markerIndex = prDescription . indexOf ( marker ) ;
139+
140+ if ( markerIndex === - 1 ) return false ;
141+
142+ // Get text after the marker
143+ const afterMarker = prDescription . substring ( markerIndex + marker . length ) ;
144+
145+ // Extract the next line or paragraph after the marker
146+ const lines = afterMarker . split ( '\n' ) . map ( line => line . trim ( ) ) . filter ( line => line . length > 0 ) ;
147+
148+ if ( lines . length === 0 ) return false ;
149+
150+ // Check if the first non-empty line contains "yes" or "_yes_"
151+ const firstLine = lines [ 0 ] . toLowerCase ( ) ;
152+ return firstLine . includes ( 'yes' ) || firstLine . includes ( '_yes_' ) ;
153+ }
154+
133155function extractReleaseNotesSummary ( prDescription ) {
134156 if ( ! prDescription ) return null ;
135157
@@ -142,13 +164,36 @@ function extractReleaseNotesSummary(prDescription) {
142164 // Get text after the marker
143165 const afterMarker = prDescription . substring ( markerIndex + marker . length ) ;
144166
145- // Extract the next line or paragraph after the marker
146- const lines = afterMarker . split ( '\n' ) . map ( line => line . trim ( ) ) . filter ( line => line . length > 0 ) ;
167+ // Split into lines and get all non-empty lines
168+ const lines = afterMarker . split ( '\n' )
169+ . map ( line => line . trim ( ) )
170+ . filter ( line => line . length > 0 ) ;
147171
148172 if ( lines . length === 0 ) return null ;
149173
150- // Return the first non-empty line after the marker
151- return lines [ 0 ] ;
174+ // Get the first non-empty line after the marker
175+ let summary = lines [ 0 ] ;
176+
177+ // Remove Microsoft Reviewers text if it exists anywhere in the summary
178+ const reviewersMarker = 'Microsoft Reviewers: [Open in CodeFlow' ;
179+ if ( summary . includes ( reviewersMarker ) ) {
180+ const reviewersIndex = summary . indexOf ( reviewersMarker ) ;
181+ summary = summary . substring ( 0 , reviewersIndex ) . trim ( ) ;
182+ }
183+
184+ // Filter out lines that contain Microsoft Reviewers text
185+ if ( ! summary || summary . length === 0 ) {
186+ // Try the next lines if the first one was entirely Microsoft Reviewers text
187+ for ( let i = 1 ; i < lines . length ; i ++ ) {
188+ const line = lines [ i ] ;
189+ if ( ! line . includes ( 'Microsoft Reviewers: [Open in CodeFlow' ) ) {
190+ summary = line ;
191+ break ;
192+ }
193+ }
194+ }
195+
196+ return summary && summary . length > 0 ? summary : null ;
152197}
153198
154199async function categorizeCommits ( commits ) {
@@ -198,15 +243,24 @@ async function categorizeCommits(commits) {
198243 // Try to get a better summary from PR description
199244 const prNumber = extractPRNumber ( commitTitle ) ;
200245 let summary = commitTitle ;
246+ let shouldInclude = true ; // Default to include if we can't determine
201247
202248 if ( prNumber ) {
203249 console . log ( `Fetching PR details for #${ prNumber } ...` ) ;
204250 const prDetails = await fetchPRDetails ( prNumber ) ;
205251 if ( prDetails ) {
206- const releaseNotesSummary = extractReleaseNotesSummary ( prDetails . body ) ;
207- if ( releaseNotesSummary ) {
208- summary = releaseNotesSummary ;
209- console . log ( `Found release notes summary for PR #${ prNumber } : ${ summary } ` ) ;
252+ // Check if this PR should be included in release notes
253+ shouldInclude = shouldIncludeInReleaseNotes ( prDetails . body ) ;
254+
255+ if ( shouldInclude ) {
256+ const releaseNotesSummary = extractReleaseNotesSummary ( prDetails . body ) ;
257+ if ( releaseNotesSummary ) {
258+ summary = releaseNotesSummary ;
259+ console . log ( `Found release notes summary for PR #${ prNumber } : ${ summary } ` ) ;
260+ }
261+ } else {
262+ console . log ( `Skipping PR #${ prNumber } - not marked for inclusion in release notes` ) ;
263+ continue ; // Skip this commit
210264 }
211265 }
212266 }
0 commit comments