From afce5df8c5c3fe8e913c20636318119a16f7bfb1 Mon Sep 17 00:00:00 2001 From: KarolGrzesiak Date: Sun, 26 Apr 2020 23:53:25 +0200 Subject: [PATCH 1/3] Update Repository to include WatchersCount --- Octokit/Models/Response/Repository.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index d768e5816e..e8d390ab3a 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount) { Url = url; HtmlUrl = htmlUrl; @@ -55,6 +55,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st AllowSquashMerge = allowSquashMerge; AllowMergeCommit = allowMergeCommit; Archived = archived; + WatchersCount = watchersCount; } public string Url { get; protected set; } @@ -99,6 +100,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public int ForksCount { get; protected set; } public int StargazersCount { get; protected set; } + + public int WatchersCount { get; protected set; } public string DefaultBranch { get; protected set; } From fcc8f2388cadf288eba228a0e7a3c0cfbca0c1bd Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sun, 7 Jun 2020 13:51:33 -0300 Subject: [PATCH 2/3] mark old field as obsolete --- Octokit/Models/Response/Repository.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index e8d390ab3a..7b6836c964 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -100,7 +100,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public int ForksCount { get; protected set; } public int StargazersCount { get; protected set; } - + public int WatchersCount { get; protected set; } public string DefaultBranch { get; protected set; } @@ -135,6 +135,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public bool HasPages { get; protected set; } + [Obsolete("Update your code to use WatchersCount as this field will stop containing data in the future")] public int SubscribersCount { get; protected set; } public long Size { get; protected set; } From 493cd0dcc5510fa96f645e1d3e57abab4a15c753 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sun, 7 Jun 2020 14:01:39 -0300 Subject: [PATCH 3/3] update test to validate new field is populated --- .../Clients/RepositoriesClientTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 820b56cad3..a32576499b 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -655,10 +655,11 @@ public async Task ReturnsSpecifiedRepository() var repository = await github.Repository.Get("haacked", "seegit"); - Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl); + Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl, ignoreCase: true); Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); + Assert.True(repository.WatchersCount > 0); } [IntegrationTest] @@ -668,10 +669,11 @@ public async Task ReturnsSpecifiedRepositoryWithRepositoryId() var repository = await github.Repository.Get(3622414); - Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl); + Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl, ignoreCase: true); Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); + Assert.True(repository.WatchersCount > 0); } [IntegrationTest]