Skip to content
This repository was archived by the owner on Sep 20, 2022. It is now read-only.

Commit a64439d

Browse files
committed
Merge pull request #45 from JakeGinnivan/Polishing
Polishing
2 parents 09e5b99 + dbdad9c commit a64439d

20 files changed

Lines changed: 361 additions & 154 deletions

NextVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.5.0

src/GitReleaseNotes.Tests/IssueTrackers/Jira/JiraIssueTrackerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public JiraIssueTrackerTests()
4242
// JiraProjectId = "JIRA"
4343
// }, toScan);
4444

45-
// Assert.Equal("Issue Title", releaseNotes.Releases[0].ReleaseNoteItems[0].Title);
45+
// Assert.Equal("Issue Title", releaseNotes.Releases[0].ReleaseNoteLines[0].Title);
4646
//}
4747

4848
private static Commit CreateCommit(string message, DateTimeOffset when)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 0.2.0 (05 January 2012)
2+
3+
**Note this release does some stuff!**
4+
5+
6+
- [2] - Edited Issue3
7+
8+
Another comment
9+
10+
Commits: [AC39885536...CA74E870F2](url/AC39885536...CA74E870F2)
11+
12+
13+
# 0.1.0 (03 January 2012)
14+
15+
## Features
16+
- [0] - Edited Issue1
17+
- [1] - Edited Issue2
18+
- [2] - Edited Issue3
19+
20+
## Fixes
21+
- [3] - Edited Issue4
22+
- [4] - Edited Issue5
23+
24+
This is a comment about the release
25+
26+
Which spans multiple lines
27+
28+
Commits: [E413A880DB...F6924D7A0B](url/E413A880DB...F6924D7A0B)

src/GitReleaseNotes.Tests/ReleaseNotesGeneratorTests.cs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void AllTagsWithNoCommitsOrIssuesAfterLastRelease()
2424

2525
var releaseNotes = ReleaseNotesGenerator.GenerateReleaseNotes(
2626
repo, issueTracker, new SemanticReleaseNotes(), new string[0],
27-
tagToStartFrom, currentReleaseInfo);
27+
tagToStartFrom, currentReleaseInfo, issueTracker.DiffUrlFormat);
2828

2929
Approvals.Verify(releaseNotes.ToString());
3030
}
@@ -45,7 +45,7 @@ public void AllTags()
4545

4646
var releaseNotes = ReleaseNotesGenerator.GenerateReleaseNotes(
4747
repo, issueTracker, new SemanticReleaseNotes(), new string[0],
48-
tagToStartFrom, currentReleaseInfo);
48+
tagToStartFrom, currentReleaseInfo, string.Empty);
4949

5050
Approvals.Verify(releaseNotes.ToString());
5151
}
@@ -86,7 +86,64 @@ public void AppendOnlyNewItems()
8686

8787
var releaseNotes = ReleaseNotesGenerator.GenerateReleaseNotes(
8888
repo, issueTracker, previousReleaseNotes, new string[0],
89-
tagToStartFrom, currentReleaseInfo);
89+
tagToStartFrom, currentReleaseInfo, string.Empty);
90+
91+
Approvals.Verify(releaseNotes.ToString());
92+
}
93+
94+
[Fact]
95+
public void KeepsCustomisations()
96+
{
97+
98+
IRepository repo;
99+
IIssueTracker issueTracker;
100+
new TestDataCreator(new DateTimeOffset(2012, 1, 1, 0, 0, 0, new TimeSpan()))
101+
.CreateRelease("0.1.0", "Issue1", "Issue2")
102+
.CreateRelease("0.2.0", "Issue3")
103+
.Build(out repo, out issueTracker);
104+
105+
var tagToStartFrom = GitRepositoryInfoFinder.GetFirstCommit(repo);
106+
var currentReleaseInfo = GitRepositoryInfoFinder.GetCurrentReleaseInfo(repo);
107+
108+
var previousReleaseNotes = SemanticReleaseNotes.Parse(@"# vNext
109+
110+
111+
Commits: ...
112+
113+
114+
# 0.2.0 (05 January 2012)
115+
116+
**Note this release does some stuff!**
117+
118+
119+
- [2] - Edited Issue3
120+
121+
Another comment
122+
123+
Commits: AC39885536...CA74E870F2
124+
125+
126+
# 0.1.0 (03 January 2012)
127+
128+
## Features
129+
- [0] - Edited Issue1
130+
- [1] - Edited Issue2
131+
- [2] - Edited Issue3
132+
133+
## Fixes
134+
- [3] - Edited Issue4
135+
- [4] - Edited Issue5
136+
137+
This is a comment about the release
138+
139+
Which spans multiple lines
140+
141+
142+
Commits: E413A880DB...F6924D7A0B");
143+
144+
var releaseNotes = ReleaseNotesGenerator.GenerateReleaseNotes(
145+
repo, issueTracker, previousReleaseNotes, new string[0],
146+
tagToStartFrom, currentReleaseInfo, "url/{0}...{1}");
90147

91148
Approvals.Verify(releaseNotes.ToString());
92149
}

src/GitReleaseNotes.Tests/SemanticReleaseNotesTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void ApproveSimpleTests()
1313
{
1414
var releaseNotes = new SemanticReleaseNotes(new[]
1515
{
16-
new SemanticRelease("", null, new List<ReleaseNoteItem>
16+
new SemanticRelease("", null, new List<IReleaseNoteLine>
1717
{
1818
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], DateTime.Now, new[]{ new Contributor("Foo Bar", "@foo", "http://url.com/foo") }),
1919
new ReleaseNoteItem("Issue 1", null, null, new string[0], DateTime.Now, new Contributor[0])
@@ -34,7 +34,7 @@ public void ItemIsCategorised()
3434
{
3535
var releaseNotes = new SemanticReleaseNotes(new[]
3636
{
37-
new SemanticRelease("", null, new List<ReleaseNoteItem>
37+
new SemanticRelease("", null, new List<IReleaseNoteLine>
3838
{
3939
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
4040
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0])
@@ -55,7 +55,7 @@ public void MultipleReleases()
5555
{
5656
var releaseNotes = new SemanticReleaseNotes(new[]
5757
{
58-
new SemanticRelease("", null, new List<ReleaseNoteItem>
58+
new SemanticRelease("", null, new List<IReleaseNoteLine>
5959
{
6060
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
6161
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0])
@@ -64,7 +64,7 @@ public void MultipleReleases()
6464
BeginningSha = "12345678",
6565
EndSha = "67890123"
6666
}),
67-
new SemanticRelease("1.2.0", new DateTimeOffset(2013, 12, 06, 0,0,0, new TimeSpan()), new List<ReleaseNoteItem>
67+
new SemanticRelease("1.2.0", new DateTimeOffset(2013, 12, 06, 0,0,0, new TimeSpan()), new List<IReleaseNoteLine>
6868
{
6969
new ReleaseNoteItem("Issue 2", "#2", new Uri("http://github.com/org/repo/issues/2"),
7070
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0]),
@@ -87,7 +87,7 @@ public void LabelOfBugIsCategorisedAsFix()
8787
{
8888
var releaseNotes = new SemanticReleaseNotes(new[]
8989
{
90-
new SemanticRelease("", null, new List<ReleaseNoteItem>
90+
new SemanticRelease("", null, new List<IReleaseNoteLine>
9191
{
9292
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new[] {"bug"}, DateTimeOffset.Now, new Contributor[0])
9393
}, new ReleaseDiffInfo
@@ -107,7 +107,7 @@ public void AdditionalCategoriesCanBeSpecifiedOnCommandLine()
107107
{
108108
var releaseNotes = new SemanticReleaseNotes(new[]
109109
{
110-
new SemanticRelease("", null, new List<ReleaseNoteItem>
110+
new SemanticRelease("", null, new List<IReleaseNoteLine>
111111
{
112112
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
113113
new[] {"internal refactoring"}, DateTimeOffset.Now, new Contributor[0])
@@ -137,7 +137,7 @@ public void CanReadBasicReleaseNotes()
137137
readReleaseNotes.Releases[0].DiffInfo.BeginningSha.ShouldBe("1234567");
138138
readReleaseNotes.Releases[0].DiffInfo.EndSha.ShouldBe("6789012");
139139
readReleaseNotes.Releases[0].ReleaseName.ShouldBe(null);
140-
readReleaseNotes.Releases[0].ReleaseNoteItems.Count.ShouldBe(1);
140+
readReleaseNotes.Releases[0].ReleaseNoteLines.Count.ShouldBe(1);
141141
readReleaseNotes.Releases[0].ReleaseNoteItems[0].Title.ShouldBe("Issue 1 [#1](http://github.com/org/repo/issues/1)");
142142
}
143143

@@ -157,9 +157,10 @@ public void CanReadReleaseNotesWithComments()
157157
readReleaseNotes.Releases[0].DiffInfo.BeginningSha.ShouldBe("1234567");
158158
readReleaseNotes.Releases[0].DiffInfo.EndSha.ShouldBe("6789012");
159159
readReleaseNotes.Releases[0].ReleaseName.ShouldBe(null);
160-
readReleaseNotes.Releases[0].ReleaseNoteItems.Count.ShouldBe(2);
161-
readReleaseNotes.Releases[0].ReleaseNoteItems[0].Title.ShouldBe("Issue 1 [#1](http://github.com/org/repo/issues/1)");
162-
readReleaseNotes.Releases[0].ReleaseNoteItems[1].Title.ShouldBe("Note: Some shiz..");
160+
readReleaseNotes.Releases[0].ReleaseNoteLines.Count.ShouldBe(3);
161+
readReleaseNotes.Releases[0].ReleaseNoteLines[0].ToString(new string[0]).ShouldBe(" - Issue 1 [#1](http://github.com/org/repo/issues/1)");
162+
readReleaseNotes.Releases[0].ReleaseNoteLines[1].ToString(new string[0]).ShouldBe(string.Empty);
163+
readReleaseNotes.Releases[0].ReleaseNoteLines[2].ToString(new string[0]).ShouldBe("Note: Some shiz..");
163164
}
164165

165166
[Fact]
@@ -176,7 +177,7 @@ public void CanReadCategorisedIssuesReleaseNotes()
176177
readReleaseNotes.Releases[0].DiffInfo.BeginningSha.ShouldBe("12345678");
177178
readReleaseNotes.Releases[0].DiffInfo.EndSha.ShouldBe("67890123");
178179
readReleaseNotes.Releases[0].ReleaseName.ShouldBe(null);
179-
readReleaseNotes.Releases[0].ReleaseNoteItems.Count.ShouldBe(1);
180+
readReleaseNotes.Releases[0].ReleaseNoteItems.Length.ShouldBe(1);
180181
readReleaseNotes.Releases[0].ReleaseNoteItems[0].Title.ShouldBe("Issue 1 [#1](http://github.com/org/repo/issues/1) +feature +new");
181182
}
182183

@@ -204,13 +205,13 @@ public void CanReadReleaseNotesContainingMultipleReleases()
204205
readReleaseNotes.Releases[0].DiffInfo.EndSha.ShouldBe("67890123");
205206
readReleaseNotes.Releases[0].ReleaseName.ShouldBe(null);
206207
readReleaseNotes.Releases[0].When.ShouldBe(null);
207-
readReleaseNotes.Releases[0].ReleaseNoteItems.Count.ShouldBe(1);
208+
readReleaseNotes.Releases[0].ReleaseNoteLines.Count.ShouldBe(1);
208209
readReleaseNotes.Releases[0].ReleaseNoteItems[0].Title.ShouldBe("Issue 1 [#1](http://github.com/org/repo/issues/1) +feature +new");
209210
readReleaseNotes.Releases[1].DiffInfo.BeginningSha.ShouldBe("asdsadaf");
210211
readReleaseNotes.Releases[1].DiffInfo.EndSha.ShouldBe("bfdsadre");
211212
readReleaseNotes.Releases[1].ReleaseName.ShouldBe("1.2.0");
212213
readReleaseNotes.Releases[1].When.ShouldBe(new DateTimeOffset(new DateTime(2013, 12, 6)));
213-
readReleaseNotes.Releases[1].ReleaseNoteItems.Count.ShouldBe(2);
214+
readReleaseNotes.Releases[1].ReleaseNoteLines.Count.ShouldBe(2);
214215
readReleaseNotes.Releases[1].ReleaseNoteItems[0].Title.ShouldBe("Issue 2 [#2](http://github.com/org/repo/issues/2) +feature");
215216
readReleaseNotes.Releases[1].ReleaseNoteItems[1].Title.ShouldBe("Issue 3 [#3](http://github.com/org/repo/issues/3) +fix");
216217
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>

src/GitReleaseNotes/BlankLine.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace GitReleaseNotes
2+
{
3+
public class BlankLine : IReleaseNoteLine
4+
{
5+
public string ToString(string[] categories)
6+
{
7+
return string.Empty;
8+
}
9+
}
10+
}

src/GitReleaseNotes/GitReleaseNotes.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
</ItemGroup>
6060
<ItemGroup>
6161
<Compile Include="ArgumentVerifier.cs" />
62+
<Compile Include="BlankLine.cs" />
6263
<Compile Include="Contributor.cs" />
64+
<Compile Include="IReleaseNoteLine.cs" />
6365
<Compile Include="ReleaseFinder.cs" />
6466
<Compile Include="FileSystem\FileSystem.cs" />
6567
<Compile Include="FileSystem\IFileSystem.cs" />
@@ -90,6 +92,7 @@
9092
<Compile Include="FileSystem\ReleaseFileWriter.cs" />
9193
<Compile Include="ReleaseInfo.cs" />
9294
<Compile Include="FileSystem\ReleaseNotesFileReader.cs" />
95+
<Compile Include="ReleaseNoteLine.cs" />
9396
<Compile Include="ReleaseNotesGenerator.cs" />
9497
<Compile Include="SemanticRelease.cs" />
9598
<Compile Include="SemanticReleaseNotes.cs" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace GitReleaseNotes
2+
{
3+
public interface IReleaseNoteLine
4+
{
5+
string ToString(string[] categories);
6+
}
7+
}

0 commit comments

Comments
 (0)