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

Commit b6b1970

Browse files
author
Jake Ginnivan
committed
Added shout outs
1 parent 8fd7f23 commit b6b1970

12 files changed

Lines changed: 69 additions & 36 deletions

src/GitReleaseNotes.Tests/IssueTrackers/GitHub/GitHubIssueTrackerTests.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using LibGit2Sharp;
88
using NSubstitute;
99
using Octokit;
10+
using Shouldly;
1011
using Xunit;
1112
using Xunit.Extensions;
1213

@@ -50,13 +51,21 @@ public void CreatesReleaseNotesForClosedGitHubIssues()
5051
Number = 1,
5152
Title = "Issue Title",
5253
Labels = new Collection<Label>(),
53-
ClosedAt = DateTimeOffset.Now
54+
ClosedAt = DateTimeOffset.Now,
55+
PullRequest = new PullRequest(),
56+
User = new User
57+
{
58+
Login = "User",
59+
Name = "Foo",
60+
Url = "http://github.com/foo"
61+
}
5462
}
5563
}.AsReadOnly()));
5664

5765
var closedIssues = _sut.GetClosedIssues(DateTimeOffset.Now.AddDays(-2));
58-
59-
Assert.Equal("Issue Title", closedIssues.Single().Title);
66+
var onlineIssue = closedIssues.Single();
67+
onlineIssue.Title.ShouldBe("Issue Title");
68+
onlineIssue.Contributors.ShouldContain(c => c.Username == "User" && c.Name == "Foo" && c.Url == "http://github.com/foo");
6069
}
6170

6271
[Fact]
@@ -65,7 +74,7 @@ public void ErrorLoggedWhenRepoIsNotSpecified()
6574
_arguments.Repo = null;
6675
var result = _sut.VerifyArgumentsAndWriteErrorsToConsole();
6776

68-
Assert.False(result);
77+
result.ShouldBe(false);
6978
_log.Received().WriteLine("GitHub repository name must be specified [/Repo .../...]");
7079
}
7180

@@ -81,11 +90,11 @@ public void RepositoryMustBeInCorrectFormat(string repo, bool success)
8190

8291
if (success)
8392
{
84-
Assert.True(result);
93+
result.ShouldBe(true);
8594
}
8695
else
8796
{
88-
Assert.False(result);
97+
result.ShouldBe(false);
8998
_log.Received().WriteLine("GitHub repository name should be in format Organisation/RepoName");
9099
}
91100
}
@@ -97,9 +106,7 @@ public void CanGetRepoFromRemote()
97106

98107
_sut.GetClosedIssues(DateTimeOffset.Now.AddDays(-2));
99108

100-
_issuesClient
101-
.Received()
102-
.GetForRepository("Org", "Repo.With.Dots", Arg.Any<RepositoryIssueRequest>());
109+
_issuesClient.Received().GetForRepository("Org", "Repo.With.Dots", Arg.Any<RepositoryIssueRequest>());
103110
}
104111

105112
[Fact]
@@ -110,7 +117,7 @@ public void MustSpecifyVersionWhenPublishFlagIsSet()
110117
_arguments.Publish = true;
111118
var result = _sut.VerifyArgumentsAndWriteErrorsToConsole();
112119

113-
Assert.False(result);
120+
result.ShouldBe(false);
114121
_log.Received().WriteLine("You must specifiy the version [/Version ...] (will be tag) when using the /Publish flag");
115122
}
116123

@@ -122,10 +129,8 @@ public void CanCreateReleaseOnGitHub()
122129
const string releaseNotesOutput = " - A thingy was fixed";
123130
_sut.PublishRelease(releaseNotesOutput);
124131

125-
_gitHubClient.Release
126-
.Received()
127-
.CreateRelease("Foo", "Baz",
128-
Arg.Is<ReleaseUpdate>(r => r.TagName == "1.2.0" && r.Body == releaseNotesOutput && r.Name == "1.2.0"));
132+
var releaseUpdateSpec = Arg.Is<ReleaseUpdate>(r => r.TagName == "1.2.0" && r.Body == releaseNotesOutput && r.Name == "1.2.0");
133+
_gitHubClient.Release.Received().CreateRelease("Foo", "Baz", releaseUpdateSpec);
129134
}
130135
}
131136
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
 - Issue 1 [#1](http://github.com/org/repo/issues/1)
1+
 - Issue 1 [#1](http://github.com/org/repo/issues/1) contributed by Foo Bar ([@foo](http://url.com/foo))
22
- Issue 1
33

44
Commits: 12345678...67890123

src/GitReleaseNotes.Tests/ReleaseNotesGeneratorTests.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public void ApproveSimpleTests()
2727
{
2828
new SemanticRelease("", null, new List<ReleaseNoteItem>
2929
{
30-
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], DateTime.Now),
31-
new ReleaseNoteItem("Issue 1", null, null, new string[0], DateTime.Now)
30+
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") }),
31+
new ReleaseNoteItem("Issue 1", null, null, new string[0], DateTime.Now, new Contributor[0])
3232
}, new ReleaseDiffInfo
3333
{
3434
BeginningSha = "12345678",
@@ -52,8 +52,8 @@ public void ApproveSimpleUpdateTests()
5252
{
5353
new SemanticRelease("", null, new List<ReleaseNoteItem>
5454
{
55-
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], DateTime.Now.AddDays(-2)),
56-
new ReleaseNoteItem("Issue 2", "#2", new Uri("http://github.com/org/repo/issues/2"), new string[0], DateTime.Now)
55+
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], DateTime.Now.AddDays(-2), new Contributor[0]),
56+
new ReleaseNoteItem("Issue 2", "#2", new Uri("http://github.com/org/repo/issues/2"), new string[0], DateTime.Now, new Contributor[0])
5757
}, new ReleaseDiffInfo
5858
{
5959
BeginningSha = "12345678",
@@ -66,7 +66,8 @@ public void ApproveSimpleUpdateTests()
6666
{
6767
new SemanticRelease("", previousReleaseNotesGeneratedOn, new List<ReleaseNoteItem>
6868
{
69-
new ReleaseNoteItem("Customised title for Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], previousReleaseNotesGeneratedOn)
69+
new ReleaseNoteItem("Customised title for Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new string[0], previousReleaseNotesGeneratedOn,
70+
new Contributor[0])
7071
}, new ReleaseDiffInfo
7172
{
7273
BeginningSha = "asd39424",
@@ -89,7 +90,7 @@ public void ItemIsCategorised()
8990
new SemanticRelease("", null, new List<ReleaseNoteItem>
9091
{
9192
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
92-
new[] {"feature"}, DateTimeOffset.Now)
93+
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0])
9394
}, new ReleaseDiffInfo
9495
{
9596
BeginningSha = "12345678",
@@ -114,7 +115,7 @@ public void MultipleReleases()
114115
new SemanticRelease("", null, new List<ReleaseNoteItem>
115116
{
116117
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
117-
new[] {"feature"}, DateTimeOffset.Now)
118+
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0])
118119
}, new ReleaseDiffInfo
119120
{
120121
BeginningSha = "12345678",
@@ -123,9 +124,9 @@ public void MultipleReleases()
123124
new SemanticRelease("1.2.0", new DateTimeOffset(2013, 12, 06, 0,0,0, new TimeSpan()), new List<ReleaseNoteItem>
124125
{
125126
new ReleaseNoteItem("Issue 2", "#2", new Uri("http://github.com/org/repo/issues/2"),
126-
new[] {"feature"}, DateTimeOffset.Now),
127+
new[] {"feature"}, DateTimeOffset.Now, new Contributor[0]),
127128
new ReleaseNoteItem("Issue 3", "#3", new Uri("http://github.com/org/repo/issues/3"),
128-
new[] {"bug"}, DateTimeOffset.Now)
129+
new[] {"bug"}, DateTimeOffset.Now, new Contributor[0])
129130
}, new ReleaseDiffInfo
130131
{
131132
BeginningSha = "asdsadaf",
@@ -149,7 +150,7 @@ public void LabelOfBugIsCategorisedAsFix()
149150
{
150151
new SemanticRelease("", null, new List<ReleaseNoteItem>
151152
{
152-
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new[] {"bug"}, DateTimeOffset.Now)
153+
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"), new[] {"bug"}, DateTimeOffset.Now, new Contributor[0])
153154
}, new ReleaseDiffInfo
154155
{
155156
BeginningSha = "12345678",
@@ -175,7 +176,7 @@ public void AdditionalCategoriesCanBeSpecifiedOnCommandLine()
175176
new SemanticRelease("", null, new List<ReleaseNoteItem>
176177
{
177178
new ReleaseNoteItem("Issue 1", "#1", new Uri("http://github.com/org/repo/issues/1"),
178-
new[] {"internal refactoring"}, DateTimeOffset.Now)
179+
new[] {"internal refactoring"}, DateTimeOffset.Now, new Contributor[0])
179180
}, new ReleaseDiffInfo
180181
{
181182
BeginningSha = "12345678",

src/GitReleaseNotes/Contributor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace GitReleaseNotes
2+
{
3+
public class Contributor
4+
{
5+
public Contributor(string name, string username, string url)
6+
{
7+
Name = name;
8+
Username = username;
9+
Url = url;
10+
}
11+
12+
public string Name { get; private set; }
13+
public string Username { get; private set; }
14+
public string Url { get; private set; }
15+
}
16+
}

src/GitReleaseNotes/GenerationStrategy/ByClosedIssues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public SemanticReleaseNotes GetReleaseNotes(Dictionary<ReleaseInfo, List<Commit>
2020
.Where(i =>
2121
(reloadLocal.Key.When == null || i.DateClosed < reloadLocal.Key.When) &&
2222
(reloadLocal.Key.PreviousReleaseDate == null || i.DateClosed > reloadLocal.Key.PreviousReleaseDate))
23-
.Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed))
23+
.Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed, i.Contributors))
2424
.ToList();
2525
semanticReleases.Add(new SemanticRelease(release.Key.Name, release.Key.When, releaseNoteItems, new ReleaseDiffInfo
2626
{

src/GitReleaseNotes/GenerationStrategy/ByMentionedCommits.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public SemanticReleaseNotes GetReleaseNotes(Dictionary<ReleaseInfo, List<Commit>
5555
var releaseNoteItems = r.IssuesForRelease.Select(i =>
5656
{
5757
var labels = i.Labels ?? new string[0];
58-
return new ReleaseNoteItem(i.Title, string.Format("{0}", i.Id), i.HtmlUrl, labels, i.DateClosed);
58+
return new ReleaseNoteItem(i.Title, string.Format("{0}", i.Id), i.HtmlUrl, labels, i.DateClosed, i.Contributors);
5959
}).ToList();
6060
return new SemanticRelease(r.ReleaseInfo.Name, r.ReleaseInfo.When, releaseNoteItems, new ReleaseDiffInfo
6161
{

src/GitReleaseNotes/GitReleaseNotes.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
</ItemGroup>
6060
<ItemGroup>
6161
<Compile Include="ArgumentVerifier.cs" />
62+
<Compile Include="Contributor.cs" />
6263
<Compile Include="GenerationStrategy\ByClosedIssues.cs" />
6364
<Compile Include="GenerationStrategy\ByMentionedCommits.cs" />
6465
<Compile Include="CommitGrouper.cs" />

src/GitReleaseNotes/IssueTrackers/GitHub/GitHubIssueTracker.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ public IEnumerable<OnlineIssue> GetClosedIssues(DateTimeOffset? since)
126126
State = ItemState.Closed
127127
});
128128
var readOnlyList = forRepository.Result;
129+
129130
return readOnlyList.Select(i => new OnlineIssue
130131
{
131132
HtmlUrl = i.HtmlUrl,
132133
Id = i.Number.ToString(CultureInfo.InvariantCulture),
133134
IssueType = i.PullRequest == null ? IssueType.Issue : IssueType.PullRequest,
134135
Labels = i.Labels.Select(l => l.Name).ToArray(),
135136
Title = i.Title,
136-
DateClosed = i.ClosedAt.Value
137+
DateClosed = i.ClosedAt.Value,
138+
Contributors = i.PullRequest == null ? new Contributor[0] : new[] { new Contributor(i.User.Name, i.User.Login, i.User.Url) }
137139
});
138140
}
139141
}

src/GitReleaseNotes/IssueTrackers/OnlineIssue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class OnlineIssue
99
public Uri HtmlUrl { get; set; }
1010
public string Title { get; set; }
1111
public string[] Labels { get; set; }
12+
public Contributor[] Contributors { get; set; }
1213
public DateTimeOffset DateClosed { get; set; }
1314
}
1415
}

src/GitReleaseNotes/ReleaseNoteItem.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ public class ReleaseNoteItem
99
private readonly Uri _htmlUrl;
1010
private readonly string[] _tags;
1111
private readonly DateTimeOffset? _resolvedOn;
12+
private Contributor[] _contributors;
1213

13-
public ReleaseNoteItem(string title, string issueNumber, Uri htmlUrl, string[] tags, DateTimeOffset? resolvedOn)
14+
public ReleaseNoteItem(string title, string issueNumber, Uri htmlUrl, string[] tags, DateTimeOffset? resolvedOn, Contributor[] contributors)
1415
{
1516
_title = title;
1617
_issueNumber = issueNumber;
1718
_htmlUrl = htmlUrl;
1819
_tags = tags ?? new string[0];
1920
_resolvedOn = resolvedOn;
21+
_contributors = contributors;
2022
}
2123

2224
public string Title
@@ -43,5 +45,7 @@ public DateTimeOffset? ResolvedOn
4345
{
4446
get { return _resolvedOn; }
4547
}
48+
49+
public Contributor[] Contributors { get { return _contributors; }}
4650
}
4751
}

0 commit comments

Comments
 (0)