Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 6e47b96

Browse files
authored
Merge pull request #425 from github/bump-octokit
Bump octokit to 0.20.0
2 parents 834e7c1 + 2956a13 commit 6e47b96

File tree

9 files changed

+57
-69
lines changed

9 files changed

+57
-69
lines changed

src/GitHub.App/Api/ApiClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
232232
{
233233
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
234234
new PullRequestRequest {
235-
State = ItemState.All,
235+
State = ItemStateFilter.All,
236236
SortProperty = PullRequestSort.Updated,
237237
SortDirection = SortDirection.Descending
238238
});

src/GitHub.App/Services/ModelService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public PullRequestCacheItem(PullRequest pr)
433433
{
434434
Title = pr.Title;
435435
Number = pr.Number;
436-
CommentCount = pr.Comments;
436+
CommentCount = pr.Comments + pr.ReviewComments;
437437
Author = new AccountCacheItem(pr.User);
438438
Assignee = pr.Assignee != null ? new AccountCacheItem(pr.Assignee) : null;
439439
CreatedAt = pr.CreatedAt;

src/UnitTests/GitHub.Api/SimpleApiClientTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ public void ReturnsFalseWhenWeHaveNotRequestedRepository()
161161

162162
private static Repository CreateRepository(int id, bool hasWiki)
163163
{
164-
return new Repository("", "", "", "", "", "", "", id, new User(), "", "", "", "", "", false, false, 0, 0, 0, "",
165-
0, null, DateTimeOffset.Now, DateTimeOffset.Now, new RepositoryPermissions(), new User(), null, null, false,
164+
return new Repository("", "", "", "", "", "", "",
165+
id, new User(), "", "", "", "", "", false, false, 0, 0, "",
166+
0, null, DateTimeOffset.Now, DateTimeOffset.Now, new RepositoryPermissions(), null, null, false,
166167
hasWiki, false);
167168
}
168169
}

src/UnitTests/GitHub.App/Models/ModelServiceTests.cs

+5-36
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public async Task NonExpiredIndexReturnsCache()
398398
var indexKey = string.Format(CultureInfo.InvariantCulture, "{0}|{1}:{2}", CacheIndex.PRPrefix, user.Login, repo.Name);
399399

400400
var prcache = Enumerable.Range(1, expected)
401-
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 0));
401+
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow));
402402

403403
// seed the cache
404404
prcache
@@ -408,7 +408,7 @@ public async Task NonExpiredIndexReturnsCache()
408408
.ToList();
409409

410410
var prlive = Observable.Range(1, expected)
411-
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Live " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 0))
411+
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Live " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow))
412412
.DelaySubscription(TimeSpan.FromMilliseconds(10));
413413

414414
apiClient.GetPullRequestsForRepository(user.Login, repo.Name).Returns(prlive);
@@ -449,7 +449,7 @@ public async Task ExpiredIndexReturnsLive()
449449
var indexKey = string.Format(CultureInfo.InvariantCulture, "{0}|{1}:{2}", CacheIndex.PRPrefix, user.Login, repo.Name);
450450

451451
var prcache = Enumerable.Range(1, expected)
452-
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 0));
452+
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow));
453453

454454
// seed the cache
455455
prcache
@@ -464,7 +464,7 @@ public async Task ExpiredIndexReturnsLive()
464464
await cache.InsertObject(indexKey, indexobj);
465465

466466
var prlive = Observable.Range(1, expected)
467-
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Live " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 0))
467+
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Live " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow))
468468
.DelaySubscription(TimeSpan.FromMilliseconds(10));
469469

470470
apiClient.GetPullRequestsForRepository(user.Login, repo.Name).Returns(prlive);
@@ -516,7 +516,7 @@ public async Task ExpiredIndexClearsItems()
516516
var indexKey = string.Format(CultureInfo.InvariantCulture, "{0}|{1}:{2}", CacheIndex.PRPrefix, user.Login, repo.Name);
517517

518518
var prcache = Enumerable.Range(1, expected)
519-
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 0));
519+
.Select(id => CreatePullRequest(user, id, ItemState.Open, "Cache " + id, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow));
520520

521521
// seed the cache
522522
prcache
@@ -570,35 +570,4 @@ public async Task ExpiredIndexClearsItems()
570570
);
571571
}
572572
}
573-
574-
static UserAndScopes CreateUserAndScopes(string login)
575-
{
576-
return new UserAndScopes(CreateOctokitUser(login), null);
577-
}
578-
579-
static User CreateOctokitUser(string login)
580-
{
581-
return new User("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, "http://url", 10, 42, "somewhere", login, "Who cares", 1, new Plan(), 1, 1, 1, "https://url", false, null, null);
582-
}
583-
584-
static Organization CreateOctokitOrganization(string login)
585-
{
586-
return new Organization("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, "http://url", 10, 42, "somewhere", login, "Who cares", 1, new Plan(), 1, 1, 1, "https://url", "billing");
587-
}
588-
589-
static Repository CreateRepository(string owner, string name)
590-
{
591-
return new Repository("https://url", "https://url", "https://url", "https://url", "https://url", "https://url", "https://url", 1, CreateOctokitUser(owner), name, "fullname", "description", "https://url", "c#", false, false, 0, 0, 0, "master", 0, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, new RepositoryPermissions(), null, null, null, true, false, false);
592-
}
593-
594-
static PullRequest CreatePullRequest(User user, int id, ItemState state, string title,
595-
DateTimeOffset createdAt, DateTimeOffset updatedAt, int commentCount)
596-
{
597-
var uri = new Uri("https://url");
598-
return new PullRequest(uri, uri, uri, uri, uri, uri,
599-
id, state, title, "", createdAt, updatedAt,
600-
null, null, null, null, user, null, false, null,
601-
commentCount, 0, 0, 0, 0,
602-
null, false);
603-
}
604573
}

src/UnitTests/GitHub.App/Models/RepositoryHostTests.cs

-15
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,4 @@ public async Task SupportsGistIsTrueWhenScopesAreNull()
217217
Assert.True(host.SupportsGist);
218218
}
219219
}
220-
221-
static UserAndScopes CreateUserAndScopes(string login, string[] scopes = null)
222-
{
223-
return new UserAndScopes(CreateOctokitUser(login), scopes);
224-
}
225-
226-
static User CreateOctokitUser(string login)
227-
{
228-
return new User("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, "http://url", 10, 42, "somewhere", login, "Who cares", 1, new Plan(), 1, 1, 1, "https://url", false, null, null);
229-
}
230-
231-
static Organization CreateOctokitOrganization(string login)
232-
{
233-
return new Organization("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, "http://url", 10, 42, "somewhere", login, "Who cares", 1, new Plan(), 1, 1, 1, "https://url", "billing");
234-
}
235220
}

src/UnitTests/GitHub.Exports.Reactive/Caches/AccountCacheItemTests.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@ public class TheConstructor : TestBaseClass
1616
[InlineData("GARBAGE", false)]
1717
public void SetsIsEnterpriseCorrectly(string htmlUrl, bool expected)
1818
{
19-
var apiAccount = CreateOctokitUser(htmlUrl);
19+
var apiAccount = CreateOctokitUser("foo", htmlUrl);
2020
var cachedAccount = new AccountCacheItem(apiAccount);
2121

2222
Assert.Equal(expected, cachedAccount.IsEnterprise);
2323
}
2424
}
25-
26-
static User CreateOctokitUser(string url)
27-
{
28-
return new User("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, url, 10, 42, "somewhere", "foo", "Who cares", 1, new Plan(), 1, 1, 1, "https://url", false, null, null);
29-
}
3025
}

src/UnitTests/GitHub.VisualStudio/Services/RepositoryPublishServiceTests.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@ public async Task CreatesRepositoryAndPushesLocalToIt()
2222
var account = Substitute.For<IAccount>();
2323
account.Login.Returns("monalisa");
2424
account.IsUser.Returns(true);
25-
var gitHubRepository = CreateOctokitRepository("https://github.com/monalisa/test");
25+
var gitHubRepository = CreateRepository(account.Login, newRepository.Name);
2626
var apiClient = Substitute.For<IApiClient>();
2727
apiClient.CreateRepository(newRepository, "monalisa", true).Returns(Observable.Return(gitHubRepository));
2828

2929
var repository = await service.PublishRepository(newRepository, account, apiClient);
3030

3131
Assert.Equal("https://github.com/monalisa/test", repository.CloneUrl);
3232
}
33-
34-
static Octokit.Repository CreateOctokitRepository(string cloneUrl)
35-
{
36-
var notCloneUrl = cloneUrl + "x";
37-
return new Octokit.Repository(notCloneUrl, notCloneUrl, cloneUrl, notCloneUrl, notCloneUrl, notCloneUrl, notCloneUrl, 1, null, null, null, null, null, null, false, false, 0, 0, 0, "master", 0, null, DateTimeOffset.Now, DateTimeOffset.Now, null, null, null, null, false, false, false);
38-
}
3933
}
4034
}

src/UnitTests/Helpers/TestBaseClass.cs

+44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using EntryExitDecoratorInterfaces;
2+
using GitHub.Models;
3+
using Octokit;
4+
using System;
25
using System.IO;
36

47
/// <summary>
@@ -18,6 +21,47 @@ public virtual void OnEntry()
1821
public virtual void OnExit()
1922
{
2023
}
24+
25+
protected static UserAndScopes CreateUserAndScopes(string login, string[] scopes = null)
26+
{
27+
return new UserAndScopes(CreateOctokitUser(login), scopes);
28+
}
29+
30+
protected static User CreateOctokitUser(string login = "login", string url = "https://url")
31+
{
32+
return new User("https://url", "bio", "blog", 1, "GitHub",
33+
DateTimeOffset.UtcNow, 0, "email", 100, 100, true, url,
34+
10, 42, "location", login, "name", 1, new Plan(),
35+
1, 1, 1, "https://url", new RepositoryPermissions(true, true, true),
36+
false, null, null);
37+
}
38+
39+
protected static Organization CreateOctokitOrganization(string login)
40+
{
41+
return new Organization("https://url", "", "", 1, "GitHub", DateTimeOffset.UtcNow, 0, "email", 100, 100, true, "http://url", 10, 42, "somewhere", login, "Who cares", 1, new Plan(), 1, 1, 1, "https://url", "billing");
42+
}
43+
44+
protected static Repository CreateRepository(string owner, string name, string domain = "github.com")
45+
{
46+
var cloneUrl = "https://" + domain + "/" + owner + "/" + name;
47+
string notCloneUrl = cloneUrl + "-x";
48+
return new Repository(notCloneUrl, notCloneUrl, cloneUrl, notCloneUrl, notCloneUrl, notCloneUrl, notCloneUrl,
49+
1, CreateOctokitUser(owner),
50+
name, "fullname", "description", notCloneUrl, "c#", false, false, 0, 0, "master",
51+
0, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow,
52+
new RepositoryPermissions(), null, null, true, false, false);
53+
}
54+
55+
protected static PullRequest CreatePullRequest(User user, int id, ItemState state, string title,
56+
DateTimeOffset createdAt, DateTimeOffset updatedAt, int commentCount = 0, int reviewCommentCount = 0)
57+
{
58+
var uri = new Uri("https://url");
59+
return new PullRequest(uri, uri, uri, uri, uri, uri,
60+
id, state, title, "", createdAt, updatedAt,
61+
null, null, null, null, user, null, false, null,
62+
commentCount, reviewCommentCount, 0, 0, 0, 0,
63+
null, false);
64+
}
2165
}
2266

2367
public class TempFileBaseClass : TestBaseClass

submodules/octokit.net

Submodule octokit.net updated 536 files

0 commit comments

Comments
 (0)