@@ -25,43 +25,73 @@ public ReleaseNotesExporter(IGitHubClient gitHubClient, Config configuration)
2525 }
2626
2727 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Design" , "CA1024:UsePropertiesWhereAppropriate" , Justification = "Not appropriate." ) ]
28- public async Task < string > ExportReleaseNotes ( )
28+ public async Task < string > ExportReleaseNotes ( string tagName )
2929 {
30- var releases = await this . gitHubClient . GetReleases ( ) ;
31-
3230 var stringBuilder = new StringBuilder ( ) ;
3331
34- if ( releases . Count > 0 )
32+ if ( string . IsNullOrEmpty ( tagName ) )
3533 {
36- foreach ( var release in releases )
34+ var releases = await this . gitHubClient . GetReleases ( ) ;
35+
36+ if ( releases . Count > 0 )
3737 {
38- if ( this . configuration . Export . IncludeCreatedDateInTitle )
39- {
40- stringBuilder . AppendLine ( string . Format ( "## {0} ({1})" , release . TagName , release . CreatedAt . ToString ( this . configuration . Export . CreatedDateStringFormat ) ) ) ;
41- }
42- else
38+ foreach ( var release in releases )
4339 {
44- stringBuilder . AppendLine ( string . Format ( "## {0}" , release . TagName ) ) ;
45- }
46-
47- stringBuilder . AppendLine ( Environment . NewLine ) ;
40+ if ( this . configuration . Export . IncludeCreatedDateInTitle )
41+ {
42+ stringBuilder . AppendLine ( string . Format ( "## {0} ({1})" , release . TagName , release . CreatedAt . ToString ( this . configuration . Export . CreatedDateStringFormat ) ) ) ;
43+ }
44+ else
45+ {
46+ stringBuilder . AppendLine ( string . Format ( "## {0}" , release . TagName ) ) ;
47+ }
4848
49- if ( this . configuration . Export . PerformRegexRemoval )
50- {
51- var regexPattern = new Regex ( this . configuration . Export . RegexText , this . configuration . Export . IsMultilineRegex ? RegexOptions . Multiline : RegexOptions . Singleline ) ;
52- var replacement = string . Empty ;
53- var replacedBody = regexPattern . Replace ( release . Body , replacement ) ;
54- stringBuilder . AppendLine ( replacedBody ) ;
55- }
56- else
57- {
58- stringBuilder . AppendLine ( release . Body ) ;
49+ stringBuilder . AppendLine ( Environment . NewLine ) ;
50+
51+ if ( this . configuration . Export . PerformRegexRemoval )
52+ {
53+ var regexPattern = new Regex ( this . configuration . Export . RegexText , this . configuration . Export . IsMultilineRegex ? RegexOptions . Multiline : RegexOptions . Singleline ) ;
54+ var replacement = string . Empty ;
55+ var replacedBody = regexPattern . Replace ( release . Body , replacement ) ;
56+ stringBuilder . AppendLine ( replacedBody ) ;
57+ }
58+ else
59+ {
60+ stringBuilder . AppendLine ( release . Body ) ;
61+ }
5962 }
6063 }
64+ else
65+ {
66+ stringBuilder . Append ( "Unable to find any releases for specified repository." ) ;
67+ }
6168 }
6269 else
6370 {
64- stringBuilder . Append ( "Unable to find any releases for specified repository." ) ;
71+ var release = await this . gitHubClient . GetSpecificRelease ( tagName ) ;
72+
73+ if ( this . configuration . Export . IncludeCreatedDateInTitle )
74+ {
75+ stringBuilder . AppendLine ( string . Format ( "## {0} ({1})" , release . TagName , release . CreatedAt . ToString ( this . configuration . Export . CreatedDateStringFormat ) ) ) ;
76+ }
77+ else
78+ {
79+ stringBuilder . AppendLine ( string . Format ( "## {0}" , release . TagName ) ) ;
80+ }
81+
82+ stringBuilder . AppendLine ( Environment . NewLine ) ;
83+
84+ if ( this . configuration . Export . PerformRegexRemoval )
85+ {
86+ var regexPattern = new Regex ( this . configuration . Export . RegexText , this . configuration . Export . IsMultilineRegex ? RegexOptions . Multiline : RegexOptions . Singleline ) ;
87+ var replacement = string . Empty ;
88+ var replacedBody = regexPattern . Replace ( release . Body , replacement ) ;
89+ stringBuilder . AppendLine ( replacedBody ) ;
90+ }
91+ else
92+ {
93+ stringBuilder . AppendLine ( release . Body ) ;
94+ }
6595 }
6696
6797 return stringBuilder . ToString ( ) ;
0 commit comments