From 528d8c58ffe1fe8361ecf5e68f5168edc31f34ad Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Sun, 19 Jan 2014 20:36:47 +0000 Subject: [PATCH 01/23] Implement Get Hooks on Repository Client --- .../Clients/RepositoriesClientTests.cs | 23 ++++++++++++++ Octokit/Clients/IRepositoriesClient.cs | 7 +++++ Octokit/Clients/RepositoriesClient.cs | 8 +++++ Octokit/Helpers/ApiUrls.cs | 11 +++++++ Octokit/Models/Response/RepositoryHook.cs | 31 +++++++++++++++++++ .../Response/RepositoryHookConfiguration.cs | 22 +++++++++++++ Octokit/Octokit-netcore45.csproj | 2 ++ Octokit/Octokit.csproj | 2 ++ 8 files changed, 106 insertions(+) create mode 100644 Octokit/Models/Response/RepositoryHook.cs create mode 100644 Octokit/Models/Response/RepositoryHookConfiguration.cs diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index bb517f26..cfa25f5f 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -249,5 +249,28 @@ namespace Octokit.Tests.Clients Assert.Equal("README", readme); } } + + public class TheGetMethodForRepositoryHooks + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.GetHooks("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Get(null, "name")); + await AssertEx.Throws(async () => await client.Get("owner", null)); + } + } } } diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 0e08da1c..a9a63396 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -135,5 +135,12 @@ namespace Octokit /// that announced this feature. /// ICommitStatusClient CommitStatus { get; } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + Task> GetHooks(string owner, string repositoryName);//todo: clarify type of collection } } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 023651ca..7fc35581 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -194,5 +194,13 @@ namespace Octokit /// that announced this feature. /// public ICommitStatusClient CommitStatus { get; private set; } + + public Task> GetHooks(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName)); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index ac2ee83f..38cbd14d 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -246,5 +246,16 @@ namespace Octokit { return "repos/{0}/{1}/statuses/{2}".FormatUri(owner, name, reference); } + + /// + /// Returns the that lists the repository hooks for the specified reference. + /// + /// The owner of the repository + /// The name of the repository + /// + public static Uri RepositoryHooks(string owner, string repositoryName) + { + return "repos/{0}/{1}/hooks".FormatUri(owner, repositoryName); + } } } diff --git a/Octokit/Models/Response/RepositoryHook.cs b/Octokit/Models/Response/RepositoryHook.cs new file mode 100644 index 00000000..e7aab83b --- /dev/null +++ b/Octokit/Models/Response/RepositoryHook.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryHook + { + public string Url { get; set; } + public DateTimeOffset CreatedAt { get; set; } + public DateTimeOffset UpdatedAt { get; set; } + public string Name { get; set; } + public IEnumerable Events { get; set; } + public bool Active { get; set; } + public RepositoryHookConfiguration Config { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Repository Hook: Name: {0} Url: {1}, Events: {2}", Name, Url, string.Join(", ", Events)); + } + } + } +} diff --git a/Octokit/Models/Response/RepositoryHookConfiguration.cs b/Octokit/Models/Response/RepositoryHookConfiguration.cs new file mode 100644 index 00000000..603967f2 --- /dev/null +++ b/Octokit/Models/Response/RepositoryHookConfiguration.cs @@ -0,0 +1,22 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryHookConfiguration + { + public string Url { get; set; } + public string ContentType { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Send {0} to {1}", ContentType, Url); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 23698df4..e50cadb6 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -156,6 +156,8 @@ + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 2134323a..f5894965 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -77,6 +77,8 @@ + + From 8a5143884e0b103573db0f1673b067bc83a229bf Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Sun, 19 Jan 2014 20:38:01 +0000 Subject: [PATCH 02/23] Comment missing on Client --- Octokit/Clients/RepositoriesClient.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 7fc35581..40f87a3c 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -195,6 +195,11 @@ namespace Octokit /// public ICommitStatusClient CommitStatus { get; private set; } + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// public Task> GetHooks(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); From 218eeecd32dfd3281412d35f9278e9a6f56c31bb Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Sun, 19 Jan 2014 20:40:24 +0000 Subject: [PATCH 03/23] remove spurious comment from dev --- Octokit/Clients/IRepositoriesClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index a9a63396..61091695 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -141,6 +141,6 @@ namespace Octokit /// /// See API documentation for more information. /// - Task> GetHooks(string owner, string repositoryName);//todo: clarify type of collection + Task> GetHooks(string owner, string repositoryName); } } From 8223bade5756c58e3abd142a330799a985f355f1 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Sun, 19 Jan 2014 21:06:37 +0000 Subject: [PATCH 04/23] Include RX client --- .../Clients/IObservableRepositoriesClient.cs | 10 ++++++++++ .../Clients/ObservableRepositoriesClient.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 75a084fd..1b9104d7 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reactive; @@ -98,5 +99,14 @@ namespace Octokit.Reactive /// that announced this feature. /// IObservableCommitStatusClient CommitStatus { get; } + + + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + IObservable> GetHooks(string owner, string repositoryName); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 05d60706..f714c37e 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -108,5 +109,14 @@ namespace Octokit.Reactive } public IObservableCommitStatusClient CommitStatus { get; private set; } + + + public IObservable> GetHooks(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.GetHooks(owner, repositoryName).ToObservable(); + } } } From a13c9fa3ccbbd4d4f305612d34f49874a610dfd6 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 14:36:36 +0000 Subject: [PATCH 05/23] Refactor to a RepositoryHooksClient --- .../Clients/ObservableRepositoriesClient.cs | 7 +- .../Clients/RepositoriesClientTests.cs | 2 +- Octokit/Clients/IRepositoriesClient.cs | 7 +- Octokit/Clients/IRepositoryHooksClient.cs | 33 +++++++++ Octokit/Clients/RepositoriesClient.cs | 18 +++-- Octokit/Clients/RepositoryHooksClient.cs | 71 +++++++++++++++++++ Octokit/Helpers/ApiUrls.cs | 12 ++++ Octokit/Models/Request/EditRepositoryHook.cs | 28 ++++++++ Octokit/Models/Request/NewRepositoryHook.cs | 25 +++++++ Octokit/Models/Response/RepositoryHook.cs | 3 +- Octokit/Octokit-netcore45.csproj | 4 ++ Octokit/Octokit.csproj | 5 +- 12 files changed, 195 insertions(+), 20 deletions(-) create mode 100644 Octokit/Clients/IRepositoryHooksClient.cs create mode 100644 Octokit/Clients/RepositoryHooksClient.cs create mode 100644 Octokit/Models/Request/EditRepositoryHook.cs create mode 100644 Octokit/Models/Request/NewRepositoryHook.cs diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index f714c37e..e3b3fd4a 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -113,10 +113,11 @@ namespace Octokit.Reactive public IObservable> GetHooks(string owner, string repositoryName) { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + throw new NotImplementedException("refactor"); + //Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + //Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.GetHooks(owner, repositoryName).ToObservable(); + //return _client.GetHooks(owner, repositoryName).ToObservable(); } } } diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index cfa25f5f..c3f9e4ee 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -258,7 +258,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.GetHooks("fake", "repo"); + client.Hooks.GetHooks("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); } diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 61091695..82216e03 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -137,10 +137,9 @@ namespace Octokit ICommitStatusClient CommitStatus { get; } /// - /// Gets the list of hooks defined for a repository + /// A client for GitHub's Repository Hooks API. /// - /// See API documentation for more information. - /// - Task> GetHooks(string owner, string repositoryName); + /// See API documentation for more information. + IRepositoryHooksClient Hooks { get; } } } diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs new file mode 100644 index 00000000..a431c8dc --- /dev/null +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IRepositoryHooksClient + { + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + Task> GetHooks(string owner, string repositoryName); + + /// + /// Gets a single hook by Id + /// + /// + /// + /// + /// + /// See API documentation for more information. + Task GetHookById(string owner, string repositoryName, int hookId); + + Task CreateHook(string owner, string repositoryName, NewRepositoryHook hook); + + Task EditHook(string owner, string repositoryName, string hookId, EditRepositoryHook hook); + + Task TestHook(string owner, string repositoryName, string hookId); + + Task DeleteHook(string owner, string repositoryName, string hookId); + } +} diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 40f87a3c..0b699092 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -21,6 +21,7 @@ namespace Octokit public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) { CommitStatus = new CommitStatusClient(apiConnection); + _hooks = new Lazy(() => new RepositoryHooksClient(apiConnection)); } /// @@ -195,17 +196,14 @@ namespace Octokit /// public ICommitStatusClient CommitStatus { get; private set; } - /// - /// Gets the list of hooks defined for a repository - /// - /// See API documentation for more information. - /// - public Task> GetHooks(string owner, string repositoryName) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Lazy _hooks; - return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName)); + /// + /// Gets a client for GitHub's Repository Hooks + /// + public IRepositoryHooksClient Hooks + { + get { return _hooks.Value; } } } } diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs new file mode 100644 index 00000000..2279284c --- /dev/null +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Repository Hooks API + /// + public class RepositoryHooksClient : ApiClient, IRepositoryHooksClient + { + /// + /// Initializes a new GitHub Repos API client. + /// + /// An API connection. + public RepositoryHooksClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + public Task> GetHooks(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName)); + } + + /// + /// Gets a single hook defined for a repository by id + /// + /// See API documentation for more information. + /// + public Task GetHookById(string owner, string repositoryName, int hookId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(hookId, "hookId"); + + return ApiConnection.Get(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId)); + } + + /// + /// Creates a hook for a repository + /// + /// See API documentation for more information. + /// + public Task CreateHook(string owner, string repositoryName, NewRepositoryHook hook) + { + throw new System.NotImplementedException(); + } + + public Task EditHook(string owner, string repositoryName, string hookId, EditRepositoryHook hook) + { + throw new System.NotImplementedException(); + } + + public Task TestHook(string owner, string repositoryName, string hookId) + { + throw new System.NotImplementedException(); + } + + public Task DeleteHook(string owner, string repositoryName, string hookId) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 38cbd14d..ffe0ab57 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -257,5 +257,17 @@ namespace Octokit { return "repos/{0}/{1}/hooks".FormatUri(owner, repositoryName); } + + /// + /// Returns the that gets the repository hook for the specified reference. + /// + /// The owner of the repository + /// The name of the repository + /// The identifier of the repository hook + /// + public static Uri RepositoryHooksById(string owner, string repositoryName, int hookId) + { + return "repos/{0}/{1}/hooks/{2}".FormatUri(owner, repositoryName, hookId); + } } } diff --git a/Octokit/Models/Request/EditRepositoryHook.cs b/Octokit/Models/Request/EditRepositoryHook.cs new file mode 100644 index 00000000..acff18c0 --- /dev/null +++ b/Octokit/Models/Request/EditRepositoryHook.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class EditRepositoryHook + { + public dynamic Config { get; set; } + public IEnumerable Events { get; set; } + public IEnumerable AddEvents { get; set; } + public IEnumerable RemoveEvents { get; set; } + public bool Active { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Repository Hook: Replacing Events: {0}, Adding Events: {1}, Removing Events: {2}", Events == null ? "no" : string.Join(", ", Events), + AddEvents == null ? "no" : string.Join(", ", AddEvents), + RemoveEvents == null ? "no" : string.Join(", ", RemoveEvents)); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/NewRepositoryHook.cs b/Octokit/Models/Request/NewRepositoryHook.cs new file mode 100644 index 00000000..2f9f5ac0 --- /dev/null +++ b/Octokit/Models/Request/NewRepositoryHook.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewRepositoryHook + { + public string Name { get; set; } + public dynamic Config { get; set; } + public IEnumerable Events { get; set; } + public bool Active { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Repository Hook: Name: {0}, Events: {1}", Name,string.Join(", ", Events)); + } + } + } +} diff --git a/Octokit/Models/Response/RepositoryHook.cs b/Octokit/Models/Response/RepositoryHook.cs index e7aab83b..92e22fdc 100644 --- a/Octokit/Models/Response/RepositoryHook.cs +++ b/Octokit/Models/Response/RepositoryHook.cs @@ -17,7 +17,8 @@ namespace Octokit public string Name { get; set; } public IEnumerable Events { get; set; } public bool Active { get; set; } - public RepositoryHookConfiguration Config { get; set; } + public dynamic Config { get; set; } + public int Id { get; set; } internal string DebuggerDisplay { diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index e50cadb6..96567512 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -59,6 +59,7 @@ + @@ -68,6 +69,7 @@ + @@ -121,6 +123,7 @@ + @@ -130,6 +133,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index f5894965..a1e23c54 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -53,17 +53,21 @@ + + + + @@ -78,7 +82,6 @@ - From 8222fd92462d65af0569cdb85708519f30daaae7 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 15:07:38 +0000 Subject: [PATCH 06/23] missing test changes & correct tests which were calling Repositories.Get --- .../Clients/RepositoriesClientTests.cs | 29 +--------- .../Clients/RepositoryHooksClientTest.cs | 57 +++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + Octokit/Clients/RepositoryHooksClient.cs | 1 - 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 Octokit.Tests/Clients/RepositoryHooksClientTest.cs diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c3f9e4ee..b3e2f28a 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -32,7 +32,7 @@ namespace Octokit.Tests.Clients await AssertEx.Throws(async () => await client.Create(null)); await AssertEx.Throws(async () => await client.Create(new NewRepository { Name = null })); } - + [Fact] public void UsesTheUserReposUrl() { @@ -224,9 +224,9 @@ namespace Octokit.Tests.Clients var readme = await reposEndpoint.GetReadme("fake", "repo"); Assert.Equal("README.md", readme.Name); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), null); - connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), + connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), null); var htmlReadme = await readme.GetHtmlContent(); Assert.Equal("README", htmlReadme); @@ -249,28 +249,5 @@ namespace Octokit.Tests.Clients Assert.Equal("README", readme); } } - - public class TheGetMethodForRepositoryHooks - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - - client.Hooks.GetHooks("fake", "repo"); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoriesClient(Substitute.For()); - - await AssertEx.Throws(async () => await client.Get(null, "name")); - await AssertEx.Throws(async () => await client.Get("owner", null)); - } - } } } diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs new file mode 100644 index 00000000..8f74631c --- /dev/null +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -0,0 +1,57 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RepositoryHooksClientTests + { + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.GetHooks("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.GetHooks(null, "name")); + await AssertEx.Throws(async () => await client.Hooks.GetHooks("owner", null)); + } + } + + public class TheGetByIdMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.GetHookById("fake", "repo", 12345678); + + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.GetHookById(null, "name", 123)); + await AssertEx.Throws(async () => await client.Hooks.GetHookById("owner", null, 123)); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 2e399b78..fbfe1789 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -66,6 +66,7 @@ + diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 2279284c..d41965e1 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -38,7 +38,6 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(hookId, "hookId"); return ApiConnection.Get(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId)); } From 170b0c459e67f7744fff0368aea530b4322f5585 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 15:13:03 +0000 Subject: [PATCH 07/23] Change method names to remove [Hooks] reference now that this is separated out - there doesn't need to be this duplicitous 'clarity' given the classes are now separate --- .../Clients/ObservableRepositoriesClient.cs | 2 +- Octokit.Tests/Clients/RepositoryHooksClientTest.cs | 12 ++++++------ Octokit/Clients/IRepositoryHooksClient.cs | 13 +++++++------ Octokit/Clients/RepositoryHooksClient.cs | 12 ++++++------ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index e3b3fd4a..fa66cea0 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -117,7 +117,7 @@ namespace Octokit.Reactive //Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); //Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - //return _client.GetHooks(owner, repositoryName).ToObservable(); + //return _client.Get(owner, repositoryName).ToObservable(); } } } diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 8f74631c..bc00f414 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -16,7 +16,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.Hooks.GetHooks("fake", "repo"); + client.Hooks.Get("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); } @@ -26,8 +26,8 @@ namespace Octokit.Tests.Clients { var client = new RepositoriesClient(Substitute.For()); - await AssertEx.Throws(async () => await client.Hooks.GetHooks(null, "name")); - await AssertEx.Throws(async () => await client.Hooks.GetHooks("owner", null)); + await AssertEx.Throws(async () => await client.Hooks.Get(null, "name")); + await AssertEx.Throws(async () => await client.Hooks.Get("owner", null)); } } @@ -39,7 +39,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.Hooks.GetHookById("fake", "repo", 12345678); + client.Hooks.GetById("fake", "repo", 12345678); connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), null); } @@ -49,8 +49,8 @@ namespace Octokit.Tests.Clients { var client = new RepositoriesClient(Substitute.For()); - await AssertEx.Throws(async () => await client.Hooks.GetHookById(null, "name", 123)); - await AssertEx.Throws(async () => await client.Hooks.GetHookById("owner", null, 123)); + await AssertEx.Throws(async () => await client.Hooks.GetById(null, "name", 123)); + await AssertEx.Throws(async () => await client.Hooks.GetById("owner", null, 123)); } } } diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs index a431c8dc..bb46186c 100644 --- a/Octokit/Clients/IRepositoryHooksClient.cs +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -10,7 +10,8 @@ namespace Octokit /// /// See API documentation for more information. /// - Task> GetHooks(string owner, string repositoryName); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + Task> Get(string owner, string repositoryName); /// /// Gets a single hook by Id @@ -20,14 +21,14 @@ namespace Octokit /// /// /// See API documentation for more information. - Task GetHookById(string owner, string repositoryName, int hookId); + Task GetById(string owner, string repositoryName, int hookId); - Task CreateHook(string owner, string repositoryName, NewRepositoryHook hook); + Task Create(string owner, string repositoryName, NewRepositoryHook hook); - Task EditHook(string owner, string repositoryName, string hookId, EditRepositoryHook hook); + Task Edit(string owner, string repositoryName, string hookId, EditRepositoryHook hook); - Task TestHook(string owner, string repositoryName, string hookId); + Task Test(string owner, string repositoryName, string hookId); - Task DeleteHook(string owner, string repositoryName, string hookId); + Task Delete(string owner, string repositoryName, string hookId); } } diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index d41965e1..a8d46533 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -21,7 +21,7 @@ namespace Octokit /// /// See API documentation for more information. /// - public Task> GetHooks(string owner, string repositoryName) + public Task> Get(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); @@ -34,7 +34,7 @@ namespace Octokit /// /// See API documentation for more information. /// - public Task GetHookById(string owner, string repositoryName, int hookId) + public Task GetById(string owner, string repositoryName, int hookId) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); @@ -47,22 +47,22 @@ namespace Octokit /// /// See API documentation for more information. /// - public Task CreateHook(string owner, string repositoryName, NewRepositoryHook hook) + public Task Create(string owner, string repositoryName, NewRepositoryHook hook) { throw new System.NotImplementedException(); } - public Task EditHook(string owner, string repositoryName, string hookId, EditRepositoryHook hook) + public Task Edit(string owner, string repositoryName, string hookId, EditRepositoryHook hook) { throw new System.NotImplementedException(); } - public Task TestHook(string owner, string repositoryName, string hookId) + public Task Test(string owner, string repositoryName, string hookId) { throw new System.NotImplementedException(); } - public Task DeleteHook(string owner, string repositoryName, string hookId) + public Task Delete(string owner, string repositoryName, string hookId) { throw new System.NotImplementedException(); } From 828b77601c70cdcc2751a12c2ccc80f7672a0cf6 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 16:16:20 +0000 Subject: [PATCH 08/23] implement members except TEST --- .../Clients/RepositoryHooksClientTest.cs | 132 ++++++++++++++++++ Octokit/Clients/IRepositoryHooksClient.cs | 33 ++++- Octokit/Clients/RepositoryHooksClient.cs | 55 ++++++-- Octokit/Helpers/ApiUrls.cs | 14 +- 4 files changed, 220 insertions(+), 14 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index bc00f414..212403e3 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -53,5 +53,137 @@ namespace Octokit.Tests.Clients await AssertEx.Throws(async () => await client.Hooks.GetById("owner", null, 123)); } } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var hook = new NewRepositoryHook(); + + client.Hooks.Create("fake", "repo", hook); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), hook); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.Create(null, "name", new NewRepositoryHook())); + await AssertEx.Throws(async () => await client.Hooks.Create("owner", null, new NewRepositoryHook())); + await AssertEx.Throws(async () => await client.Hooks.Create("owner", "name", null)); + } + + [Fact] + public void UsesTheSuppliedHook() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var newRepositoryHook = new NewRepositoryHook { Name = "aName" }; + + client.Hooks.Create("owner", "repo", newRepositoryHook); + + connection.Received().Post(Arg.Any(), newRepositoryHook); + } + } + + public class TheEditMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var hook = new EditRepositoryHook(); + + client.Hooks.Edit("fake", "repo", 12345678, hook); + + connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678"), hook); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.Edit(null, "name", 12345678, new EditRepositoryHook())); + await AssertEx.Throws(async () => await client.Hooks.Edit("owner", null, 12345678, new EditRepositoryHook())); + await AssertEx.Throws(async () => await client.Hooks.Edit("owner", "name", 12345678, null)); + } + + [Fact] + public void UsesTheSuppliedHook() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var editRepositoryHook = new EditRepositoryHook() { Active = false }; + + client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook); + + connection.Received().Patch(Arg.Any(), editRepositoryHook); + } + } + + + public class TheTestMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.Test("fake", "repo", 12345678); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests"), null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.Test(null, "name", 12345678)); + await AssertEx.Throws(async () => await client.Hooks.Test("owner", null, 12345678)); + } + + [Fact] + public void CallsPost() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.Test("owner", "repo", 12345678); + + connection.Received().Post(Arg.Any(), Arg.Is(o => o == null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Hooks.Delete("fake", "repo", 12345678); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Hooks.Delete(null, "name", 12345678)); + await AssertEx.Throws(async () => await client.Hooks.Delete("owner", null, 12345678)); + } + } } } diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs index bb46186c..18ea51e9 100644 --- a/Octokit/Clients/IRepositoryHooksClient.cs +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -8,7 +8,7 @@ namespace Octokit /// /// Gets the list of hooks defined for a repository /// - /// See API documentation for more information. + /// See API documentation for more information. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] Task> Get(string owner, string repositoryName); @@ -23,12 +23,37 @@ namespace Octokit /// See API documentation for more information. Task GetById(string owner, string repositoryName, int hookId); + /// + /// Creates a hook for a repository + /// + /// See API documentation for more information. + /// Task Create(string owner, string repositoryName, NewRepositoryHook hook); - Task Edit(string owner, string repositoryName, string hookId, EditRepositoryHook hook); + /// + /// Edits a hook for a repository + /// + /// See API documentation for more information. + /// + Task Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook); - Task Test(string owner, string repositoryName, string hookId); + /// + /// Tests a hook for a repository + /// + /// See API documentation for more information. + /// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook + /// is not subscribed to push events, the server will respond with 204 but no test POST will be generated. + /// + Task Test(string owner, string repositoryName, int hookId); - Task Delete(string owner, string repositoryName, string hookId); + /// + /// Deletes a hook for a repository + /// + /// + /// + /// + /// See API documentation for more information. + /// + Task Delete(string owner, string repositoryName, int hookId); } } diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index a8d46533..a508e124 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit @@ -39,7 +40,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return ApiConnection.Get(ApiUrls.RepositoryHooksById(owner, repositoryName, hookId)); + return ApiConnection.Get(ApiUrls.RepositoryHookById(owner, repositoryName, hookId)); } /// @@ -49,22 +50,58 @@ namespace Octokit /// public Task Create(string owner, string repositoryName, NewRepositoryHook hook) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(hook, "hook"); + + return ApiConnection.Post(ApiUrls.RepositoryHooks(owner, repositoryName), hook); } - public Task Edit(string owner, string repositoryName, string hookId, EditRepositoryHook hook) + /// + /// Edits a hook for a repository + /// + /// See API documentation for more information. + /// + public Task Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(hook, "hook"); + + return ApiConnection.Patch(ApiUrls.RepositoryHookById(owner, repositoryName, hookId), hook); } - public Task Test(string owner, string repositoryName, string hookId) + /// + /// Tests a hook for a repository + /// + /// See API documentation for more information. + /// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook + /// is not subscribed to push events, the server will respond with 204 but no test POST will be generated. + /// + public Task Test(string owner, string repositoryName, int hookId) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); + + //Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + //Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + //return ApiConnection.Post(ApiUrls.RepositoryHookTest(owner, repositoryName, hookId), null); } - public Task Delete(string owner, string repositoryName, string hookId) + /// + /// Deletes a hook for a repository + /// + /// + /// + /// + /// See API documentation for more information. + /// + public Task Delete(string owner, string repositoryName, int hookId) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return ApiConnection.Delete(ApiUrls.RepositoryHookById(owner, repositoryName, hookId)); } } } \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index ffe0ab57..e254160f 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -265,9 +265,21 @@ namespace Octokit /// The name of the repository /// The identifier of the repository hook /// - public static Uri RepositoryHooksById(string owner, string repositoryName, int hookId) + public static Uri RepositoryHookById(string owner, string repositoryName, int hookId) { return "repos/{0}/{1}/hooks/{2}".FormatUri(owner, repositoryName, hookId); } + + /// + /// Returns the that can tests a specified repository hook + /// + /// The owner of the repository + /// The name of the repository + /// The identifier of the repository hook + /// + public static Uri RepositoryHookTest(string owner, string repositoryName, int hookId) + { + return "repos/{0}/{1}/hooks/{2}/tests".FormatUri(owner, repositoryName, hookId); + } } } From 7cc66aad154b682a430abefcda210884bb4d2e0c Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 16:31:30 +0000 Subject: [PATCH 09/23] complete test method with stub class used for serialization --- Octokit.Tests/Clients/RepositoryHooksClientTest.cs | 5 ++--- Octokit/Clients/RepositoryHooksClient.cs | 8 +++----- Octokit/Models/Request/TestRepositoryHook.cs | 12 ++++++++++++ Octokit/Octokit.csproj | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Octokit/Models/Request/TestRepositoryHook.cs diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 212403e3..c94dc0a4 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -128,7 +128,6 @@ namespace Octokit.Tests.Clients } } - public class TheTestMethod { [Fact] @@ -139,7 +138,7 @@ namespace Octokit.Tests.Clients client.Hooks.Test("fake", "repo", 12345678); - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests"), null); + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks/12345678/tests"), Arg.Any()); } [Fact] @@ -159,7 +158,7 @@ namespace Octokit.Tests.Clients client.Hooks.Test("owner", "repo", 12345678); - connection.Received().Post(Arg.Any(), Arg.Is(o => o == null)); + connection.Received().Post(Arg.Any(), Arg.Any()); } } diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index a508e124..89710f41 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -80,12 +80,10 @@ namespace Octokit /// public Task Test(string owner, string repositoryName, int hookId) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - //Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - //Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - - //return ApiConnection.Post(ApiUrls.RepositoryHookTest(owner, repositoryName, hookId), null); + return ApiConnection.Post(ApiUrls.RepositoryHookTest(owner, repositoryName, hookId), new TestRepositoryHook()); } /// diff --git a/Octokit/Models/Request/TestRepositoryHook.cs b/Octokit/Models/Request/TestRepositoryHook.cs new file mode 100644 index 00000000..f04f1f70 --- /dev/null +++ b/Octokit/Models/Request/TestRepositoryHook.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + public class TestRepositoryHook + { + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a1e23c54..1d968537 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -69,6 +69,7 @@ + From 740fd9cf53b7196ff88b78bc96d9ec5aa12a2fab Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 16:32:47 +0000 Subject: [PATCH 10/23] missing file --- Octokit/Octokit-netcore45.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 96567512..e732ae79 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -138,6 +138,7 @@ + From 5f038b8d1f8ead8adf0845cfbb521952d1bb216e Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 17:50:18 +0000 Subject: [PATCH 11/23] rx client fixup --- .../Clients/IObservableRepositoriesClient.cs | 8 +- .../IObservableRepositoryHooksClient.cs | 56 +++++++++ .../Clients/ObservableRepositoriesClient.cs | 15 +-- .../ObservableRepositoryHooksClient.cs | 106 ++++++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 2 + 5 files changed, 174 insertions(+), 13 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 1b9104d7..132fe953 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -100,13 +100,9 @@ namespace Octokit.Reactive /// IObservableCommitStatusClient CommitStatus { get; } - - /// - /// Gets the list of hooks defined for a repository + /// Gets a client for GitHub's Repository Hooks /// - /// See API documentation for more information. - /// - IObservable> GetHooks(string owner, string repositoryName); + IObservableRepositoryHooksClient Hooks { get; } } } diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs new file mode 100644 index 00000000..fa247ea0 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Reactive; + +namespace Octokit.Reactive.Clients +{ + public interface IObservableRepositoryHooksClient + { + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + IObservable> Get(string owner, string repositoryName); + + /// + /// Gets a single hook defined for a repository by id + /// + /// See API documentation for more information. + /// + IObservable GetById(string owner, string repositoryName, int hookId); + + /// + /// Creates a hook for a repository + /// + /// See API documentation for more information. + /// + IObservable Create(string owner, string repositoryName, NewRepositoryHook hook); + + /// + /// Edits a hook for a repository + /// + /// See API documentation for more information. + /// + IObservable Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook); + + /// + /// Tests a hook for a repository + /// + /// See API documentation for more information. + /// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook + /// is not subscribed to push events, the server will respond with 204 but no test POST will be generated. + /// + IObservable Test(string owner, string repositoryName, int hookId); + + /// + /// Deletes a hook for a repository + /// + /// + /// + /// + /// See API documentation for more information. + /// + IObservable Delete(string owner, string repositoryName, int hookId); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index fa66cea0..1c64b5b2 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -18,6 +18,8 @@ namespace Octokit.Reactive _client = client.Repository; _connection = client.Connection; CommitStatus = new ObservableCommitStatusClient(client); + var apiConnection = new ApiConnection(_connection); + _hooks = new Lazy( () => new RepositoryHooksClient(apiConnection)); } /// @@ -109,15 +111,14 @@ namespace Octokit.Reactive } public IObservableCommitStatusClient CommitStatus { get; private set; } + Lazy _hooks; - - public IObservable> GetHooks(string owner, string repositoryName) + /// + /// Gets a client for GitHub's Repository Hooks + /// + public IRepositoryHooksClient Hooks { - throw new NotImplementedException("refactor"); - //Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - //Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - - //return _client.Get(owner, repositoryName).ToObservable(); + get { return _hooks.Value; } } } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs new file mode 100644 index 00000000..0a420ea1 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive.Clients +{ + public class ObservableRepositoryHooksClient : IObservableRepositoryHooksClient + { + readonly IRepositoriesClient _client; + readonly IConnection _connection; + + public ObservableRepositoryHooksClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Repository; + _connection = client.Connection; + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// + public IObservable> Get(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.Hooks.Get(owner, repositoryName).ToObservable(); + } + + /// + /// Gets a single hook defined for a repository by id + /// + /// See API documentation for more information. + /// + public IObservable GetById(string owner, string repositoryName, int hookId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.Hooks.GetById(owner, repositoryName, hookId).ToObservable(); + } + + /// + /// Creates a hook for a repository + /// + /// See API documentation for more information. + /// + public IObservable Create(string owner, string repositoryName, NewRepositoryHook hook) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(hook, "hook"); + + return _client.Hooks.Create(owner, repositoryName, hook).ToObservable(); + } + + /// + /// Edits a hook for a repository + /// + /// See API documentation for more information. + /// + public IObservable Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(hook, "hook"); + + return _client.Hooks.Edit(owner, repositoryName, hookId, hook).ToObservable(); + } + + /// + /// Tests a hook for a repository + /// + /// See API documentation for more information. + /// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook + /// is not subscribed to push events, the server will respond with 204 but no test POST will be generated. + /// + public IObservable Test(string owner, string repositoryName, int hookId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.Hooks.Test(owner, repositoryName, hookId).ToObservable(); + } + + /// + /// Deletes a hook for a repository + /// + /// + /// + /// + /// See API documentation for more information. + /// + public IObservable Delete(string owner, string repositoryName, int hookId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.Hooks.Delete(owner, repositoryName, hookId).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 2bdad6a6..499965f3 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -71,6 +71,7 @@ Properties\SolutionInfo.cs + @@ -80,6 +81,7 @@ + From 144358b93ddde07714b2acb0c05936a05acc20ae Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Mon, 20 Jan 2014 17:57:19 +0000 Subject: [PATCH 12/23] incorrect namespace --- Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs | 2 +- Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index fa247ea0..7db6f8fa 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Reactive; -namespace Octokit.Reactive.Clients +namespace Octokit.Reactive { public interface IObservableRepositoryHooksClient { diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 0a420ea1..59674da4 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; -namespace Octokit.Reactive.Clients +namespace Octokit.Reactive { public class ObservableRepositoryHooksClient : IObservableRepositoryHooksClient { From c6f073947590d4373861755051a85c231a522187 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Tue, 21 Jan 2014 07:15:45 +0000 Subject: [PATCH 13/23] remove references to lazy, correct inappropriate use of non-reactive RepositoryHooksClient --- Octokit.Reactive/Clients/ObservableRepositoriesClient.cs | 5 ++--- Octokit/Clients/RepositoriesClient.cs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 1c64b5b2..cd807261 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -19,7 +19,7 @@ namespace Octokit.Reactive _connection = client.Connection; CommitStatus = new ObservableCommitStatusClient(client); var apiConnection = new ApiConnection(_connection); - _hooks = new Lazy( () => new RepositoryHooksClient(apiConnection)); + Hooks = new RepositoryHooksClient(apiConnection); } /// @@ -111,14 +111,13 @@ namespace Octokit.Reactive } public IObservableCommitStatusClient CommitStatus { get; private set; } - Lazy _hooks; /// /// Gets a client for GitHub's Repository Hooks /// public IRepositoryHooksClient Hooks { - get { return _hooks.Value; } + get; private set; } } } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 0b699092..7ae85aca 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -21,7 +21,7 @@ namespace Octokit public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) { CommitStatus = new CommitStatusClient(apiConnection); - _hooks = new Lazy(() => new RepositoryHooksClient(apiConnection)); + Hooks = new RepositoryHooksClient(apiConnection); } /// @@ -196,14 +196,13 @@ namespace Octokit /// public ICommitStatusClient CommitStatus { get; private set; } - Lazy _hooks; /// /// Gets a client for GitHub's Repository Hooks /// public IRepositoryHooksClient Hooks { - get { return _hooks.Value; } + get; private set; } } } From a70fc80f29bc13b2a8bf3afa0327b9e133d7ae6e Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Tue, 21 Jan 2014 07:17:12 +0000 Subject: [PATCH 14/23] refactor to remove duplication --- .../Clients/ObservableRepositoryHooksClient.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 59674da4..6025f053 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -7,15 +7,13 @@ namespace Octokit.Reactive { public class ObservableRepositoryHooksClient : IObservableRepositoryHooksClient { - readonly IRepositoriesClient _client; - readonly IConnection _connection; + readonly IRepositoryHooksClient _client; public ObservableRepositoryHooksClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - _client = client.Repository; - _connection = client.Connection; + _client = client.Repository.Hooks; } /// @@ -28,7 +26,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Hooks.Get(owner, repositoryName).ToObservable(); + return _client.Get(owner, repositoryName).ToObservable(); } /// @@ -41,7 +39,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Hooks.GetById(owner, repositoryName, hookId).ToObservable(); + return _client.GetById(owner, repositoryName, hookId).ToObservable(); } /// @@ -55,7 +53,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); Ensure.ArgumentNotNull(hook, "hook"); - return _client.Hooks.Create(owner, repositoryName, hook).ToObservable(); + return _client.Create(owner, repositoryName, hook).ToObservable(); } /// @@ -69,7 +67,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); Ensure.ArgumentNotNull(hook, "hook"); - return _client.Hooks.Edit(owner, repositoryName, hookId, hook).ToObservable(); + return _client.Edit(owner, repositoryName, hookId, hook).ToObservable(); } /// @@ -84,7 +82,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Hooks.Test(owner, repositoryName, hookId).ToObservable(); + return _client.Test(owner, repositoryName, hookId).ToObservable(); } /// @@ -100,7 +98,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Hooks.Delete(owner, repositoryName, hookId).ToObservable(); + return _client.Delete(owner, repositoryName, hookId).ToObservable(); } } } From 3410d28ba057ff7b4cd3cff6c0b6212fc9cb85f4 Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Tue, 21 Jan 2014 07:22:44 +0000 Subject: [PATCH 15/23] address code analysis issue --- Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs | 1 + Octokit.Reactive/Clients/ObservableRepositoriesClient.cs | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index 7db6f8fa..fb6b939c 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -11,6 +11,7 @@ namespace Octokit.Reactive /// /// See API documentation for more information. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] IObservable> Get(string owner, string repositoryName); /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index cd807261..9e8fbbc1 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -18,8 +18,7 @@ namespace Octokit.Reactive _client = client.Repository; _connection = client.Connection; CommitStatus = new ObservableCommitStatusClient(client); - var apiConnection = new ApiConnection(_connection); - Hooks = new RepositoryHooksClient(apiConnection); + Hooks = new ObservableRepositoryHooksClient(client); } /// @@ -115,7 +114,7 @@ namespace Octokit.Reactive /// /// Gets a client for GitHub's Repository Hooks /// - public IRepositoryHooksClient Hooks + public IObservableRepositoryHooksClient Hooks { get; private set; } From 0c806d7298852b11f98a252ead6b300c3695e13f Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Wed, 22 Jan 2014 21:54:43 +0000 Subject: [PATCH 16/23] Implementation of RepositoryForks api --- Octokit.Reactive/Octokit.Reactive.csproj | 2 ++ Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 2 ++ Octokit.Tests/Octokit.Tests.csproj | 1 + Octokit/Clients/IRepositoriesClient.cs | 6 ++++++ Octokit/Clients/RepositoriesClient.cs | 11 ++++++++++- Octokit/Helpers/ApiUrls.cs | 11 +++++++++++ Octokit/Octokit-netcore45.csproj | 3 +++ Octokit/Octokit.csproj | 3 +++ 8 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 499965f3..faf5030e 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -72,6 +72,7 @@ Properties\SolutionInfo.cs + @@ -86,6 +87,7 @@ + diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index 803627b3..c554b667 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -58,6 +58,8 @@ + + diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index fbfe1789..d3f952c0 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -66,6 +66,7 @@ + diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 82216e03..15940ef2 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -141,5 +141,11 @@ namespace Octokit /// /// See API documentation for more information. IRepositoryHooksClient Hooks { get; } + + + /// + /// Gets a client for GitHub's Repository Hooks + /// + IRepositoryForksClient Forks { get; } } } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 7ae85aca..1e5656b2 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -22,6 +22,7 @@ namespace Octokit { CommitStatus = new CommitStatusClient(apiConnection); Hooks = new RepositoryHooksClient(apiConnection); + Forks = new RepositoryForksClient(apiConnection); } /// @@ -196,7 +197,6 @@ namespace Octokit /// public ICommitStatusClient CommitStatus { get; private set; } - /// /// Gets a client for GitHub's Repository Hooks /// @@ -204,5 +204,14 @@ namespace Octokit { get; private set; } + + /// + /// Gets a client for GitHub's Repository Forks + /// + public IRepositoryForksClient Forks + { + get; + private set; + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index e254160f..0de3348c 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -281,5 +281,16 @@ namespace Octokit { return "repos/{0}/{1}/hooks/{2}/tests".FormatUri(owner, repositoryName, hookId); } + + /// + /// Returns the that lists the repository forks for the specified reference. + /// + /// The owner of the repository + /// The name of the repository + /// + public static Uri RepositoryForks(string owner, string repositoryName) + { + return "repos/{0}/{1}/forks".FormatUri(owner, repositoryName); + } } } diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index e732ae79..971243eb 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -59,6 +59,7 @@ + @@ -69,6 +70,7 @@ + @@ -133,6 +135,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 1d968537..dae1427d 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -53,9 +53,11 @@ + + @@ -67,6 +69,7 @@ + From e623632c3d84a614fccdded3208249e872537abb Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Sun, 26 Jan 2014 05:22:32 +0000 Subject: [PATCH 17/23] missing files --- .../IObservableRepositoryForksClient.cs | 26 +++++++ .../ObservableRepositoryForksClient.cs | 49 +++++++++++++ .../Clients/RepositoryForksClientTests.cs | 71 +++++++++++++++++++ Octokit/Clients/IRepositoryForksClient.cs | 25 +++++++ Octokit/Clients/RepositoryForksClient.cs | 44 ++++++++++++ Octokit/Models/Request/NewRepositoryFork.cs | 22 ++++++ 6 files changed, 237 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs create mode 100644 Octokit.Tests/Clients/RepositoryForksClientTests.cs create mode 100644 Octokit/Clients/IRepositoryForksClient.cs create mode 100644 Octokit/Clients/RepositoryForksClient.cs create mode 100644 Octokit/Models/Request/NewRepositoryFork.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs new file mode 100644 index 00000000..ed73fc72 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Reactive +{ + public interface IObservableRepositoryForksClient + { + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + IObservable> Get(string owner, string repositoryName); + + /// + /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. + /// + /// See API documentation for more information. + /// + IObservable Create(string owner, string repositoryName, NewRepositoryFork fork); + } +} diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs new file mode 100644 index 00000000..1e07afc1 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservableRepositoryForksClient : IObservableRepositoryForksClient + { + readonly IRepositoryForksClient _client; + + /// + /// Initializes a new GitHub Repos Fork API client. + /// + /// + public ObservableRepositoryForksClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + _client = client.Repository.Forks; + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public IObservable> Get(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return _client.Get(owner, repositoryName).ToObservable(); + } + + /// + /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. + /// + /// See API documentation for more information. + /// + public IObservable Create(string owner, string repositoryName, NewRepositoryFork fork) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(fork, "fork"); + + return _client.Create(owner, repositoryName, fork).ToObservable(); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs new file mode 100644 index 00000000..d640ef88 --- /dev/null +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs @@ -0,0 +1,71 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RepositoryForksClientTests + { + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.Forks.Get("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Forks.Get(null, "name")); + await AssertEx.Throws(async () => await client.Forks.Get("owner", null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var newRepositoryFork = new NewRepositoryFork(); + + client.Forks.Create("fake", "repo", newRepositoryFork); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Forks.Create(null, "name", new NewRepositoryFork())); + await AssertEx.Throws(async () => await client.Forks.Create("owner", null, new NewRepositoryFork())); + await AssertEx.Throws(async () => await client.Forks.Create("owner", "name", null)); + } + + [Fact] + public void UsesTheSuppliedHook() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + var newRepositoryFork = new NewRepositoryFork { Organization = "aName" }; + + client.Forks.Create("owner", "repo", newRepositoryFork); + + connection.Received().Post(Arg.Any(), newRepositoryFork); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs new file mode 100644 index 00000000..28756aef --- /dev/null +++ b/Octokit/Clients/IRepositoryForksClient.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IRepositoryForksClient + { + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + Task> Get(string owner, string repositoryName); + + /// + /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. + /// + /// See API documentation for more information. + /// + Task Create(string owner, string repositoryName, NewRepositoryFork fork); + } +} diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs new file mode 100644 index 00000000..70af7f5f --- /dev/null +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class RepositoryForksClient : ApiClient, IRepositoryForksClient + { + /// + /// Initializes a new GitHub Repos Fork API client. + /// + /// An API connection. + public RepositoryForksClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public Task> Get(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName)); + } + + /// + /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. + /// + /// See API documentation for more information. + /// + public Task Create(string owner, string repositoryName, NewRepositoryFork fork) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(fork, "fork"); + + return ApiConnection.Post(ApiUrls.RepositoryForks(owner, repositoryName), fork); + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/NewRepositoryFork.cs b/Octokit/Models/Request/NewRepositoryFork.cs new file mode 100644 index 00000000..86d97ba8 --- /dev/null +++ b/Octokit/Models/Request/NewRepositoryFork.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewRepositoryFork + { + public string Organization { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Repository Hook: Organization: {0}", Organization); + } + } + } +} \ No newline at end of file From 433f182e163859a901f2ccfd516181a8ffca1a2a Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Tue, 18 Feb 2014 16:46:04 +0000 Subject: [PATCH 18/23] add missing files into mono assembly --- Octokit/Clients/RepositoriesClient.cs | 6 +++--- Octokit/Clients/RepositoryHooksClient.cs | 10 +++++----- Octokit/Octokit-Mono.csproj | 9 +++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 2d32ae26..3c46a4fb 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -217,15 +217,16 @@ namespace Octokit public ICommitStatusClient CommitStatus { get; private set; } /// - /// Gets a client for GitHub's Repository Hooks + /// A client for GitHub's Repository Hooks API. /// + /// See API documentation for more information. public IRepositoryHooksClient Hooks { get; private set; } /// - /// Gets a client for GitHub's Repository Forks + /// Gets a client for GitHub's Repository Hooks /// public IRepositoryForksClient Forks { @@ -233,7 +234,6 @@ namespace Octokit private set; } - /// /// A client for GitHub's Repo Collaborators. /// /// diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 89710f41..01b3381c 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -4,9 +4,6 @@ using System.Threading.Tasks; namespace Octokit { - /// - /// A client for GitHub's Repository Hooks API - /// public class RepositoryHooksClient : ApiClient, IRepositoryHooksClient { /// @@ -31,10 +28,13 @@ namespace Octokit } /// - /// Gets a single hook defined for a repository by id + /// Gets a single hook by Id /// - /// See API documentation for more information. + /// + /// + /// /// + /// See API documentation for more information. public Task GetById(string owner, string repositoryName, int hookId) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index ddb25017..aeae5886 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -60,6 +60,8 @@ + + @@ -73,6 +75,8 @@ + + @@ -85,6 +89,7 @@ + @@ -93,6 +98,8 @@ + + @@ -102,6 +109,7 @@ + @@ -132,6 +140,7 @@ + From c597449f1e00faf47bf04235084ed0e33b08357b Mon Sep 17 00:00:00 2001 From: Andy Cross Date: Thu, 20 Feb 2014 08:56:08 +0000 Subject: [PATCH 19/23] fixup csproject files that are not part of the main .sln - xamarin studio mono things --- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 4 ++++ Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj | 4 ++++ Octokit.Reactive/Octokit.Reactive-Monotouch.csproj | 4 ++++ Octokit/Octokit-MonoAndroid.csproj | 9 +++++++++ Octokit/Octokit-Monotouch.csproj | 9 +++++++++ 5 files changed, 30 insertions(+) diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 66ffd4e9..a18bb520 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -135,6 +135,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index 25009426..dbbf669d 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -144,6 +144,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 8a071338..7db12c32 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -139,6 +139,10 @@ + + + + diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 283271d8..5ee08c22 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -227,6 +227,7 @@ + @@ -243,10 +244,18 @@ + + + + + + + + diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 4082510c..994edbb5 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -287,6 +287,15 @@ + + + + + + + + + \ No newline at end of file From 581cc111e4c8322b20d13345a4069c31e673f1a7 Mon Sep 17 00:00:00 2001 From: John Du Hart Date: Mon, 19 May 2014 20:56:59 -0400 Subject: [PATCH 20/23] Adding clients and models to Portable project --- Octokit/Octokit-Portable.csproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index efb76c6f..649031fb 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -84,6 +84,8 @@ + + @@ -105,6 +107,8 @@ + + @@ -165,6 +169,7 @@ + @@ -184,6 +189,8 @@ + + @@ -199,6 +206,7 @@ + @@ -242,6 +250,8 @@ + + From 568220de91cfd5fdc8bd3dfd40f3cdc83bc760a6 Mon Sep 17 00:00:00 2001 From: John Du Hart Date: Mon, 19 May 2014 21:20:27 -0400 Subject: [PATCH 21/23] Oops, missing tag --- Octokit/Clients/IRepositoriesClient.cs | 1 + Octokit/Clients/RepositoriesClient.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index dfda9bac..16dcc567 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -164,6 +164,7 @@ namespace Octokit /// IRepositoryForksClient Forks { get; } + /// /// A client for GitHub's Repo Collaborators. /// /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 0f94856b..2bf947f2 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -273,6 +273,7 @@ namespace Octokit private set; } + /// /// A client for GitHub's Repo Collaborators. /// /// From 7b9b06f49506f918203eaa14528e183377dd1c8f Mon Sep 17 00:00:00 2001 From: John Du Hart Date: Mon, 19 May 2014 22:47:52 -0400 Subject: [PATCH 22/23] Cleaned up interfaces and implementetation so convention tests pass --- .../Clients/IObservableRepositoriesClient.cs | 9 ++++++++- .../Clients/IObservableRepositoryForksClient.cs | 2 +- .../Clients/IObservableRepositoryHooksClient.cs | 2 +- .../Clients/ObservableRepositoriesClient.cs | 15 ++++++++++----- .../Clients/ObservableRepositoryForksClient.cs | 7 +++++-- .../Clients/ObservableRepositoryHooksClient.cs | 7 +++++-- Octokit/Clients/IRepositoriesClient.cs | 6 +++--- Octokit/Clients/RepositoriesClient.cs | 5 +++-- 8 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index cc172b19..fac8cec4 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -126,9 +126,16 @@ namespace Octokit.Reactive IObservableRepositoryCommentsClient RepositoryComments { get; } /// - /// Gets a client for GitHub's Repository Hooks + /// A client for GitHub's Repository Hooks API. /// + /// See Hooks API documentation for more information. IObservableRepositoryHooksClient Hooks { get; } + + /// + /// A client for GitHub's Repository Forks API. + /// + /// See Forks API documentation for more information. + IObservableRepositoryForksClient Forks { get; } /// /// Gets all the branches for the specified repository. diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs index ed73fc72..db9da5a7 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive /// See API documentation for more information. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] - IObservable> Get(string owner, string repositoryName); + IObservable Get(string owner, string repositoryName); /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index fb6b939c..8147f5af 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -12,7 +12,7 @@ namespace Octokit.Reactive /// See API documentation for more information. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] - IObservable> Get(string owner, string repositoryName); + IObservable Get(string owner, string repositoryName); /// /// Gets a single hook defined for a repository by id diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 42e6c10f..3513d041 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -21,6 +21,7 @@ namespace Octokit.Reactive _connection = client.Connection; CommitStatus = new ObservableCommitStatusClient(client); Hooks = new ObservableRepositoryHooksClient(client); + Forks = new ObservableRepositoryForksClient(client); RepoCollaborators = new ObservableRepoCollaboratorsClient(client); Deployment = new ObservableDeploymentsClient(client); Statistics = new ObservableStatisticsClient(client); @@ -192,12 +193,16 @@ namespace Octokit.Reactive public IObservableRepositoryCommentsClient RepositoryComments { get; private set; } /// - /// Gets a client for GitHub's Repository Hooks + /// A client for GitHub's Repository Hooks API. /// - public IObservableRepositoryHooksClient Hooks - { - get; private set; - } + /// See Hooks API documentation for more information. + public IObservableRepositoryHooksClient Hooks { get; private set; } + + /// + /// A client for GitHub's Repository Forks API. + /// + /// See Forks API documentation for more information. + public IObservableRepositoryForksClient Forks { get; private set; } /// /// Gets all the branches for the specified repository. diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs index 1e07afc1..36acb3b6 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; +using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableRepositoryForksClient : IObservableRepositoryForksClient { readonly IRepositoryForksClient _client; + readonly IConnection _connection; /// /// Initializes a new GitHub Repos Fork API client. @@ -17,6 +19,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); _client = client.Repository.Forks; + _connection = client.Connection; } /// @@ -24,12 +27,12 @@ namespace Octokit.Reactive /// /// See API documentation for more information. /// - public IObservable> Get(string owner, string repositoryName) + public IObservable Get(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Get(owner, repositoryName).ToObservable(); + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName)); } /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 6025f053..9694c353 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -2,18 +2,21 @@ using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableRepositoryHooksClient : IObservableRepositoryHooksClient { readonly IRepositoryHooksClient _client; + readonly IConnection _connection; public ObservableRepositoryHooksClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Repository.Hooks; + _connection = client.Connection; } /// @@ -21,12 +24,12 @@ namespace Octokit.Reactive /// /// See API documentation for more information. /// - public IObservable> Get(string owner, string repositoryName) + public IObservable Get(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _client.Get(owner, repositoryName).ToObservable(); + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryHooks(owner, repositoryName)); } /// diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 16dcc567..d1406f5c 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -155,13 +155,13 @@ namespace Octokit /// /// A client for GitHub's Repository Hooks API. /// - /// See API documentation for more information. + /// See Hooks API documentation for more information. IRepositoryHooksClient Hooks { get; } - /// - /// Gets a client for GitHub's Repository Hooks + /// A client for GitHub's Repository Forks API. /// + /// See Forks API documentation for more information. IRepositoryForksClient Forks { get; } /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 2bf947f2..f41db0c2 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -258,15 +258,16 @@ namespace Octokit /// /// A client for GitHub's Repository Hooks API. /// - /// See API documentation for more information. + /// See Hooks API documentation for more information. public IRepositoryHooksClient Hooks { get; private set; } /// - /// Gets a client for GitHub's Repository Hooks + /// A client for GitHub's Repository Forks API. /// + /// See Forks API documentation for more information. public IRepositoryForksClient Forks { get; From 0cd5283131f2cac93554f933030b6ebd2a3cec49 Mon Sep 17 00:00:00 2001 From: John Du Hart Date: Mon, 19 May 2014 23:13:05 -0400 Subject: [PATCH 23/23] Cleaned up using statements --- .../Clients/IObservableRepositoryForksClient.cs | 7 ++----- .../Clients/IObservableRepositoryHooksClient.cs | 4 ++-- .../Clients/ObservableRepositoryForksClient.cs | 2 -- .../Clients/ObservableRepositoryHooksClient.cs | 1 - Octokit/Clients/IRepositoryForksClient.cs | 5 ++--- Octokit/Clients/IRepositoryHooksClient.cs | 3 ++- Octokit/Clients/RepositoryForksClient.cs | 3 +-- Octokit/Clients/RepositoryHooksClient.cs | 3 +-- 8 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs index db9da5a7..4131b0e5 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive { @@ -13,7 +10,7 @@ namespace Octokit.Reactive /// /// See API documentation for more information. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] IObservable Get(string owner, string repositoryName); /// diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index 8147f5af..e8089f61 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reactive; namespace Octokit.Reactive @@ -11,7 +11,7 @@ namespace Octokit.Reactive /// /// See API documentation for more information. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] IObservable Get(string owner, string repositoryName); /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs index 36acb3b6..bba8e985 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Reactive.Threading.Tasks; -using System.Threading.Tasks; using Octokit.Reactive.Internal; namespace Octokit.Reactive diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 9694c353..8b8d5fa3 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs index 28756aef..049e2969 100644 --- a/Octokit/Clients/IRepositoryForksClient.cs +++ b/Octokit/Clients/IRepositoryForksClient.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace Octokit @@ -12,7 +11,7 @@ namespace Octokit /// /// See API documentation for more information. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] Task> Get(string owner, string repositoryName); /// diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs index 18ea51e9..c9ba580e 100644 --- a/Octokit/Clients/IRepositoryHooksClient.cs +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace Octokit @@ -10,7 +11,7 @@ namespace Octokit /// /// See API documentation for more information. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] Task> Get(string owner, string repositoryName); /// diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index 70af7f5f..aa346aad 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 01b3381c..b6d98b69 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit