@@ -40,7 +40,21 @@ public PageGenerationService(WhatsNewConfiguration configuration) =>
4040 /// </summary>
4141 public async Task WriteMarkdownFile ( string ? existingMarkdownFile = null )
4242 {
43- await ProcessPullRequests ( ) ;
43+ var totalPRs = await ProcessPullRequests ( ) ;
44+
45+ if ( totalPRs == 0 )
46+ {
47+ var color = Console . ForegroundColor ;
48+ Console . ForegroundColor = ConsoleColor . Red ;
49+ Console . WriteLine ( "No PRs found." ) ;
50+ Console . WriteLine ( "This is likely a problem with one of:" ) ;
51+ Console . WriteLine ( "\t - the date range" ) ;
52+ Console . WriteLine ( "\t - the required label" ) ;
53+ Console . WriteLine ( "\t - GitHub permissions" ) ;
54+ Console . WriteLine ( "Exiting." ) ;
55+ Console . ForegroundColor = color ;
56+ return ;
57+ }
4458
4559 if ( string . IsNullOrWhiteSpace ( existingMarkdownFile ) )
4660 {
@@ -150,23 +164,30 @@ private async Task WriteNewDocInformation(TextWriter stream, bool singleFile)
150164 var allDocs = from change in _majorChanges
151165 from area in repo . Areas
152166 where change . Value . Heading == area . Heading
153- orderby area . Heading
154167 group change by area . Heading into headingGroup
155168 select headingGroup ;
156169
157170 var rootDirectoryHeading = ( from area in repo . Areas
158171 where area . Names . FirstOrDefault ( ) == "."
159172 select area . Heading ) . FirstOrDefault ( ) ;
160173
161- foreach ( var docArea in allDocs )
174+ foreach ( var area in repo . Areas )
162175 {
163- var areaHeading = docArea . Key ;
164- var isRootDirectoryArea = areaHeading == rootDirectoryHeading ;
165-
166176 // Don't write anything for blank areas.
167- if ( areaHeading is null )
177+ if ( area is null )
168178 continue ;
169- await stream . WriteLineAsync ( $ "{ ( singleFile ? "###" : "##" ) } { areaHeading } ") ;
179+ var docArea = allDocs . FirstOrDefault ( da => da . Key == area . Heading ) ;
180+ if ( docArea is null )
181+ {
182+ Console . WriteLine ( $ "No changes found for { area . Heading } ") ;
183+ continue ;
184+ } else
185+ {
186+ Console . WriteLine ( $ "Writing changes for { area . Heading } ") ;
187+ }
188+ var isRootDirectoryArea = area . Heading == rootDirectoryHeading ;
189+
190+ await stream . WriteLineAsync ( $ "{ ( singleFile ? "###" : "##" ) } { area . Heading } ") ;
170191 await stream . WriteLineAsync ( ) ;
171192
172193 writeDocNodes ( true ) ;
@@ -274,6 +295,7 @@ void writeDocNodes(bool isNew)
274295
275296 private async Task WriteContributorInformation ( TextWriter stream )
276297 {
298+ Console . WriteLine ( "Writing contributors" ) ;
277299 var allContributors = from c in _contributors
278300 orderby c . login
279301 group c by ( c . login , c . name ) into stats
@@ -301,23 +323,24 @@ group c by (c.login, c.name) into stats
301323 }
302324 }
303325
304- private async Task ProcessPullRequests ( )
326+ private async Task < int > ProcessPullRequests ( )
305327 {
306328 var repo = _configuration . Repository ;
307329 var client = _configuration . GitHubClient ;
308330 var ospoClient = _configuration . OspoClient ;
309331
310- await processPRs ( ) ;
332+ var totalPRs = await processPRs ( ) ;
311333
312334 // If processing a private repo, fetch the PRs & community contributors from
313335 // the accompanying public repo. Merge private results with public results.
314336 if ( repo . IsPrivateRepo )
315337 {
316338 repo . Name = repo . Name . Replace ( PrivateRepoNameSuffix , string . Empty ) ;
317- await processPRs ( ) ;
339+ totalPRs += await processPRs ( ) ;
318340 }
341+ return totalPRs ;
319342
320- async Task processPRs ( )
343+ async Task < int > processPRs ( )
321344 {
322345 Console . ForegroundColor = ConsoleColor . DarkMagenta ;
323346 Console . WriteLine ( $ "== { repo . Owner } /{ repo . Name } ({ repo . Branch } ) ==", Console . ForegroundColor ) ;
@@ -328,8 +351,10 @@ async Task processPRs()
328351 client , repo . Owner , repo . Name , repo . Branch , repo . InclusionCriteria . Labels , _configuration . DateRange ) ;
329352 var authorLoginFTECache = new Dictionary < string , bool ? > ( ) ;
330353
354+ var totalPRs = 0 ;
331355 await foreach ( var item in query . PerformQuery ( ) )
332356 {
357+ totalPRs ++ ;
333358 var prNumber = item . Number ;
334359 Console . WriteLine ( $ "Processing PR { prNumber } ") ;
335360
@@ -358,6 +383,7 @@ async Task processPRs()
358383 Console . WriteLine ( $ "{ index } . { distinctExcludedContributors [ index - 1 ] } ") ;
359384 }
360385 Console . WriteLine ( ) ;
386+ return totalPRs ;
361387 }
362388 }
363389
0 commit comments