Skip to content

Commit 2955a78

Browse files
committed
(GH-21) Expanded YAML Configuration
- To include options for creating release notes - Options for exporting release notes - Changed Tests to include changing FakeRepo to FakeRepository
1 parent f384435 commit 2955a78

14 files changed

+134
-37
lines changed

Source/GitHubReleaseManager.Cli/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static int Main(string[] args)
8282
var exportSubOptions = baseSubOptions as ExportSubOptions;
8383
if (exportSubOptions != null)
8484
{
85-
result = ExportReleasesAsync(exportSubOptions).Result;
85+
result = ExportReleasesAsync(exportSubOptions, fileSystem).Result;
8686
}
8787
}
8888

@@ -170,13 +170,14 @@ private static async Task<int> CloseAndPublishReleaseAsync(PublishSubOptions sub
170170
}
171171
}
172172

173-
private static async Task<int> ExportReleasesAsync(ExportSubOptions subOptions)
173+
private static async Task<int> ExportReleasesAsync(ExportSubOptions subOptions, IFileSystem fileSystem)
174174
{
175175
try
176176
{
177177
var github = subOptions.CreateGitHubClient();
178+
var configuration = ConfigurationProvider.Provide(subOptions.TargetPath, fileSystem);
178179

179-
var releasesMarkdown = await ExportReleases(github, subOptions.RepositoryOwner, subOptions.RepositoryName);
180+
var releasesMarkdown = await ExportReleases(github, subOptions.RepositoryOwner, subOptions.RepositoryName, configuration);
180181

181182
using (var sw = new StreamWriter(File.Open(subOptions.FileOutputPath, FileMode.OpenOrCreate)))
182183
{
@@ -220,9 +221,9 @@ private static async Task CreateRelease(GitHubClient github, string owner, strin
220221
}
221222
}
222223

223-
private static async Task<string> ExportReleases(GitHubClient github, string owner, string repository)
224+
private static async Task<string> ExportReleases(GitHubClient github, string owner, string repository, Config configuration)
224225
{
225-
var releaseNotesExporter = new ReleaseNotesExporter(new DefaultGitHubClient(github, owner, repository));
226+
var releaseNotesExporter = new ReleaseNotesExporter(new DefaultGitHubClient(github, owner, repository), configuration);
226227

227228
var result = await releaseNotesExporter.GetReleases();
228229

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SingularCommitsNoIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepo/commits/1.2.3).
1+
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepository/commits/1.2.3).
22

33

44
### Where to get it

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SingularCommitsSingularIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepo/commits/1.2.3) which resulted in [1 issue](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
1+
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [1 issue](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
22

33

44
__Bug__

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SingularCommitsSomeIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepo/commits/1.2.3) which resulted in [3 issues](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
1+
As part of this release we had [1 commit](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [3 issues](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
22

33

44
__Bug__

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SomeCommitsNoIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepo/commits/1.2.3).
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3).
22

33

44
### Where to get it

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SomeCommitsSingularIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepo/commits/1.2.3) which resulted in [1 issue](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [1 issue](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
22

33

44
__Bug__

Source/GitHubReleaseManager.Tests/ReleaseNotesBuilderTests.SomeCommitsSomeIssues.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepo/commits/1.2.3) which resulted in [3 issues](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
1+
As part of this release we had [5 commits](https://github.com/TestUser/FakeRepository/commits/1.2.3) which resulted in [3 issues](https://github.com/FakeRepo/issues/issues?milestone=0&state=closed) being closed.
22

33

44
__Bug__

Source/GitHubReleaseManager/Configuration/Config.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,30 @@
77
namespace GitHubReleaseManager.Configuration
88
{
99
using System.Collections.Generic;
10-
1110
using YamlDotNet.Serialization;
1211

1312
public class Config
1413
{
1514
public Config()
1615
{
17-
this.ExportRegex = @"### Where to get it(\r\n)*You can .*\)";
16+
this.Create = new CreateConfig
17+
{
18+
IncludeFooter = true,
19+
FooterHeading = "Where to get it",
20+
FooterContent = "You can download this release from [chocolatey](https://chocolatey.org/packages/ChocolateyGUI/{milestone})",
21+
FooterIncludesMilestone = true,
22+
MilestoneReplaceText = "{milestone}"
23+
};
24+
25+
this.Export = new ExportConfig
26+
{
27+
IncludeCreatedDateInTitle = true,
28+
CreatedDateStringFormat = "MMMM dd, yyyy",
29+
PerformRegexRemoval = true,
30+
RegexText = @"### Where to get it(\r\n)*You can .*\)",
31+
IsMultilineRegex = true
32+
};
33+
1834
this.IssueLabelsInclude = new List<string>
1935
{
2036
"Bug",
@@ -28,8 +44,11 @@ public Config()
2844
};
2945
}
3046

31-
[YamlMember(Alias = "export-regex")]
32-
public string ExportRegex { get; set; }
47+
[YamlMember(Alias = "create")]
48+
public CreateConfig Create { get; private set; }
49+
50+
[YamlMember(Alias = "export")]
51+
public ExportConfig Export { get; private set; }
3352

3453
[YamlMember(Alias = "issue-labels-include")]
3554
public IList<string> IssueLabelsInclude { get; private set; }

Source/GitHubReleaseManager/Configuration/ConfigSerializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void Write(Config config, TextWriter writer)
3232
serializer.Serialize(writer, config);
3333
}
3434

35+
// TODO: Need to expand this to include all options
3536
public static void WriteSample(TextWriter writer)
3637
{
3738
if (writer == null)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="CreateConfig.cs" company="gep13">
3+
// Copyright (c) gep13. All rights reserved.
4+
// </copyright>
5+
//-----------------------------------------------------------------------
6+
7+
namespace GitHubReleaseManager.Configuration
8+
{
9+
using YamlDotNet.Serialization;
10+
11+
public class CreateConfig
12+
{
13+
[YamlMember(Alias = "include-footer")]
14+
public bool IncludeFooter { get; set; }
15+
16+
[YamlMember(Alias = "footer-heading")]
17+
public string FooterHeading { get; set; }
18+
19+
[YamlMember(Alias = "footer-content")]
20+
public string FooterContent { get; set; }
21+
22+
[YamlMember(Alias = "footer-includes-milestone")]
23+
public bool FooterIncludesMilestone { get; set; }
24+
25+
[YamlMember(Alias = "milestone-replace-text")]
26+
public string MilestoneReplaceText { get; set; }
27+
}
28+
}

0 commit comments

Comments
 (0)