From b1917364cccef9274aa47a4992208db84ef830a1 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 3 Jan 2016 12:00:36 +0200 Subject: [PATCH] Fixes #1035 Replaces #1042 --- .../Clients/IObservableRepositoriesClient.cs | 9 ++++++ .../Clients/ObservableRepositoriesClient.cs | 14 +++++++++- .../ObservableRepositoryCommitsClients.cs | 2 +- .../Clients/RepositoryCommitsClientTests.cs | 4 +-- .../ObservableRepositoriesClientTests.cs | 28 +++++++++---------- Octokit/Clients/IRepositoriesClient.cs | 9 ++++++ Octokit/Clients/RepositoriesClient.cs | 12 ++++++++ 7 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 22b16663..05a8563c 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -313,8 +313,17 @@ namespace Octokit.Reactive /// /// See the Commits API documentation for more details /// + [System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] IObservableRepositoryCommitsClient Commits { get; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + IObservableRepositoryCommitsClient Commit { get; } + /// /// Client for managing pull requests. /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 9d11813b..bad46c87 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -33,7 +33,10 @@ namespace Octokit.Reactive RepositoryComments = new ObservableRepositoryCommentsClient(client); #pragma warning restore CS0618 // Type or member is obsolete Comment = new ObservableRepositoryCommentsClient(client); +#pragma warning disable CS0618 // Type or member is obsolete Commits = new ObservableRepositoryCommitsClient(client); +#pragma warning restore CS0618 // Type or member is obsolete + Commit = new ObservableRepositoryCommitsClient(client); DeployKeys = new ObservableRepositoryDeployKeysClient(client); Content = new ObservableRepositoryContentsClient(client); Merging = new ObservableMergingClient(client); @@ -429,7 +432,7 @@ namespace Octokit.Reactive /// public IObservable Compare(string owner, string name, string @base, string head) { - return _client.Commits.Compare(owner, name, @base, head).ToObservable(); + return _client.Commit.Compare(owner, name, @base, head).ToObservable(); } /// @@ -455,8 +458,17 @@ namespace Octokit.Reactive /// /// See the Commits API documentation for more details /// + [Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] public IObservableRepositoryCommitsClient Commits { get; private set; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + public IObservableRepositoryCommitsClient Commit { get; private set; } + /// /// Client for managing pull requests. /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index a4fb81d1..7982485e 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNull(client, "client"); _connection = client.Connection; - _commit = client.Repository.Commits; + _commit = client.Repository.Commit; } /// diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index bd6b9485..95464917 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -17,7 +17,7 @@ public class RepositoryCommitsClientTests { var client = Helper.GetAuthenticatedClient(); - _fixture = client.Repository.Commits; + _fixture = client.Repository.Commit; } [IntegrationTest] @@ -99,7 +99,7 @@ public class RepositoryCommitsClientTests { _github = Helper.GetAuthenticatedClient(); - _fixture = _github.Repository.Commits; + _fixture = _github.Repository.Commit; _context = _github.CreateRepositoryContext("source-repo").Result; } diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index c0e66b86..5e5ef53c 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -246,12 +246,12 @@ namespace Octokit.Tests.Reactive { var client = new ObservableRepositoriesClient(Substitute.For()); - Assert.Throws(() => client.Commits.Get(null, "repo", "reference")); - Assert.Throws(() => client.Commits.Get("owner", null, "reference")); - Assert.Throws(() => client.Commits.Get("owner", "repo", null)); - Assert.Throws(() => client.Commits.Get("", "repo", "reference")); - Assert.Throws(() => client.Commits.Get("owner", "", "reference")); - Assert.Throws(() => client.Commits.Get("owner", "repo", "")); + Assert.Throws(() => client.Commit.Get(null, "repo", "reference")); + Assert.Throws(() => client.Commit.Get("owner", null, "reference")); + Assert.Throws(() => client.Commit.Get("owner", "repo", null)); + Assert.Throws(() => client.Commit.Get("", "repo", "reference")); + Assert.Throws(() => client.Commit.Get("owner", "", "reference")); + Assert.Throws(() => client.Commit.Get("owner", "repo", "")); } [Fact] @@ -260,9 +260,9 @@ namespace Octokit.Tests.Reactive var github = Substitute.For(); var client = new ObservableRepositoriesClient(github); - client.Commits.Get("owner", "repo", "reference"); + client.Commit.Get("owner", "repo", "reference"); - github.Repository.Commits.Received(1).Get("owner", "repo", "reference"); + github.Repository.Commit.Received(1).Get("owner", "repo", "reference"); } } @@ -273,11 +273,11 @@ namespace Octokit.Tests.Reactive { var client = new ObservableRepositoriesClient(Substitute.For()); - Assert.Throws(() => client.Commits.GetAll(null, "repo")); - Assert.Throws(() => client.Commits.GetAll("owner", null)); - Assert.Throws(() => client.Commits.GetAll("owner", "repo", null)); - Assert.Throws(() => client.Commits.GetAll("", "repo")); - Assert.Throws(() => client.Commits.GetAll("owner", "")); + Assert.Throws(() => client.Commit.GetAll(null, "repo")); + Assert.Throws(() => client.Commit.GetAll("owner", null)); + Assert.Throws(() => client.Commit.GetAll("owner", "repo", null)); + Assert.Throws(() => client.Commit.GetAll("", "repo")); + Assert.Throws(() => client.Commit.GetAll("owner", "")); } [Fact] @@ -287,7 +287,7 @@ namespace Octokit.Tests.Reactive var client = new ObservableRepositoriesClient(github); var expected = new Uri("repos/owner/repo/commits", UriKind.Relative); - client.Commits.GetAll("owner", "repo"); + client.Commit.GetAll("owner", "repo"); github.Connection.Received(1).Get>(expected, Arg.Any>(), null); } diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 603d1242..321691a3 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -259,8 +259,17 @@ namespace Octokit /// /// See the Commits API documentation for more details /// + [System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] IRepositoryCommitsClient Commits { get; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + IRepositoryCommitsClient Commit { get; } + /// /// Client for GitHub's Repository Merging API /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 51d16197..6b30dfc1 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -36,7 +36,10 @@ namespace Octokit RepositoryComments = new RepositoryCommentsClient(apiConnection); #pragma warning restore CS0618 // Type or member is obsolete Comment = new RepositoryCommentsClient(apiConnection); +#pragma warning disable CS0618 // Type or member is obsolete Commits = new RepositoryCommitsClient(apiConnection); +#pragma warning restore CS0618 // Type or member is obsolete + Commit = new RepositoryCommitsClient(apiConnection); DeployKeys = new RepositoryDeployKeysClient(apiConnection); Merging = new MergingClient(apiConnection); Content = new RepositoryContentsClient(apiConnection); @@ -376,8 +379,17 @@ namespace Octokit /// /// See the Commits API documentation for more details /// + [Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] public IRepositoryCommitsClient Commits { get; private set; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + public IRepositoryCommitsClient Commit { get; private set; } + /// /// Client for GitHub's Repository Merging API ///