From 0cc37f861d9f4dd4865c8d0fe048703ffe1a2d10 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 6 Jun 2016 14:16:44 +0700 Subject: [PATCH] added overloads on I(Observable)RepositoryCommitsClient --- .../IObservableRepositoryCommitsClients.cs | 60 ++++++++++++ .../ObservableRepositoryCommitsClients.cs | 90 ++++++++++++++++++ Octokit/Clients/IRepositoryCommitsClient.cs | 60 ++++++++++++ Octokit/Clients/RepositoryCommitsClient.cs | 91 +++++++++++++++++++ 4 files changed, 301 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs index 9624cabf..4b6f0a6d 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs @@ -22,6 +22,16 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] IObservable Compare(string owner, string name, string @base, string head); + /// + /// Compare two references in a repository + /// + /// The ID of the repository + /// The reference to use as the base commit + /// The reference to use as the head commit + /// A of for the specified references. + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] + IObservable Compare(int repositoryId, string @base, string head); + /// /// Gets all commits for a given repository /// @@ -33,6 +43,16 @@ namespace Octokit.Reactive Justification = "Method makes a network request")] IObservable Get(string owner, string name, string reference); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// The reference for the commit + /// A of for the specified commit SHA. + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + IObservable Get(int repositoryId, string reference); + /// /// Gets all commits for a given repository /// @@ -41,6 +61,13 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// A of s for the specified repository. + IObservable GetAll(int repositoryId); + /// /// Gets all commits for a given repository /// @@ -50,6 +77,14 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name, ApiOptions options); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s for the specified repository. + IObservable GetAll(int repositoryId, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -59,6 +94,14 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// A of s for the specified repository. + IObservable GetAll(int repositoryId, CommitRequest request); + /// /// Gets all commits for a given repository /// @@ -69,6 +112,15 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name, CommitRequest request, ApiOptions options); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// A of s for the specified repository. + IObservable GetAll(int repositoryId, CommitRequest request, ApiOptions options); + /// /// Get the SHA-1 of a commit reference /// @@ -77,5 +129,13 @@ namespace Octokit.Reactive /// The repository reference /// A of for the specified repository reference. IObservable GetSha1(string owner, string name, string reference); + + /// + /// Get the SHA-1 of a commit reference + /// + /// The ID of the repository + /// The repository reference + /// A of for the specified repository reference. + IObservable GetSha1(int repositoryId, string reference); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index e852827b..1689fe35 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -36,6 +36,18 @@ namespace Octokit.Reactive return _commit.Compare(owner, name, @base, head).ToObservable(); } + /// + /// Compare two references in a repository + /// + /// The ID of the repository + /// The reference to use as the base commit + /// The reference to use as the head commit + /// A of for the specified references. + public IObservable Compare(int repositoryId, string @base, string head) + { + return _commit.Compare(repositoryId, @base, head).ToObservable(); + } + /// /// Gets all commits for a given repository /// @@ -52,6 +64,19 @@ namespace Octokit.Reactive return _commit.Get(owner, name, reference).ToObservable(); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// The reference for the commit + /// A of for the specified commit SHA. + public IObservable Get(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return _commit.Get(repositoryId, reference).ToObservable(); + } + /// /// Gets all commits for a given repository /// @@ -66,6 +91,16 @@ namespace Octokit.Reactive return GetAll(owner, name, new CommitRequest(), ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId) + { + return GetAll(repositoryId, new CommitRequest(), ApiOptions.None); + } + /// /// Gets all commits for a given repository /// @@ -82,6 +117,19 @@ namespace Octokit.Reactive return GetAll(owner, name, new CommitRequest(), options); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAll(repositoryId, new CommitRequest(), options); + } + /// /// Gets all commits for a given repository /// @@ -98,6 +146,19 @@ namespace Octokit.Reactive return GetAll(owner, name, request, ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId, CommitRequest request) + { + Ensure.ArgumentNotNull(request, "request"); + + return GetAll(repositoryId, request, ApiOptions.None); + } + /// /// Gets all commits for a given repository /// @@ -111,10 +172,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(repositoryId), request.ToParametersDictionary(), options); + } + /// /// Get the SHA-1 of a commit reference /// @@ -130,5 +207,18 @@ namespace Octokit.Reactive return _commit.GetSha1(owner, name, reference).ToObservable(); } + + /// + /// Get the SHA-1 of a commit reference + /// + /// The ID of the repository + /// The repository reference + /// A of for the specified repository reference. + public IObservable GetSha1(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return _commit.GetSha1(repositoryId, reference).ToObservable(); + } } } diff --git a/Octokit/Clients/IRepositoryCommitsClient.cs b/Octokit/Clients/IRepositoryCommitsClient.cs index bb1f24dd..3ac895f2 100644 --- a/Octokit/Clients/IRepositoryCommitsClient.cs +++ b/Octokit/Clients/IRepositoryCommitsClient.cs @@ -23,6 +23,16 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] Task Compare(string owner, string name, string @base, string head); + /// + /// Compare two references in a repository + /// + /// The ID of the repository + /// The reference to use as the base commit + /// The reference to use as the head commit + /// A for the specified references. + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] + Task Compare(int repositoryId, string @base, string head); + /// /// Gets a single commit for a given repository /// @@ -34,6 +44,16 @@ namespace Octokit Justification = "Makes a network request")] Task Get(string owner, string name, string reference); + /// + /// Gets a single commit for a given repository + /// + /// The ID of the repository + /// The reference for the commit (SHA) + /// A for the specified commit SHA. + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Makes a network request")] + Task Get(int repositoryId, string reference); + /// /// Gets all commits for a given repository /// @@ -42,6 +62,13 @@ namespace Octokit /// A of s for the specified repository. Task> GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// A of s for the specified repository. + Task> GetAll(int repositoryId); + /// /// Gets all commits for a given repository /// @@ -51,6 +78,14 @@ namespace Octokit /// A of s for the specified repository. Task> GetAll(string owner, string name, ApiOptions options); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s for the specified repository. + Task> GetAll(int repositoryId, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -60,6 +95,14 @@ namespace Octokit /// A of s for the specified repository. Task> GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// A of s for the specified repository. + Task> GetAll(int repositoryId, CommitRequest request); + /// /// Gets all commits for a given repository /// @@ -70,6 +113,15 @@ namespace Octokit /// A of s for the specified repository. Task> GetAll(string owner, string name, CommitRequest request, ApiOptions options); + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// A of s for the specified repository. + Task> GetAll(int repositoryId, CommitRequest request, ApiOptions options); + /// /// Get the SHA-1 of a commit reference /// @@ -78,5 +130,13 @@ namespace Octokit /// The repository reference /// A for the specified repository reference. Task GetSha1(string owner, string name, string reference); + + /// + /// Get the SHA-1 of a commit reference + /// + /// The ID of the repository + /// The repository reference + /// A for the specified repository reference. + Task GetSha1(int repositoryId, string reference); } } diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index 33afcebd..3af33bd2 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -34,6 +34,21 @@ namespace Octokit return ApiConnection.Get(ApiUrls.RepoCompare(owner, name, @base, head)); } + /// + /// Compare two references in a repository + /// + /// The ID of the repository + /// The reference to use as the base commit + /// The reference to use as the head commit + /// A for the specified references. + public Task Compare(int repositoryId, string @base, string head) + { + Ensure.ArgumentNotNullOrEmptyString(@base, "base"); + Ensure.ArgumentNotNullOrEmptyString(head, "head"); + + return ApiConnection.Get(ApiUrls.RepoCompare(repositoryId, @base, head)); + } + /// /// Gets a single commit for a given repository /// @@ -50,6 +65,19 @@ namespace Octokit return ApiConnection.Get(ApiUrls.RepositoryCommit(owner, name, reference)); } + /// + /// Gets a single commit for a given repository + /// + /// The ID of the repository + /// The reference for the commit (SHA) + /// A for the specified commit SHA. + public Task Get(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Get(ApiUrls.RepositoryCommit(repositoryId, reference)); + } + /// /// Gets all commits for a given repository /// @@ -64,6 +92,16 @@ namespace Octokit return GetAll(owner, name, new CommitRequest(), ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// A of s for the specified repository. + public Task> GetAll(int repositoryId) + { + return GetAll(repositoryId, new CommitRequest(), ApiOptions.None); + } + /// /// Gets all commits for a given repository /// @@ -79,6 +117,17 @@ namespace Octokit return GetAll(owner, name, new CommitRequest(), options); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s for the specified repository. + public Task> GetAll(int repositoryId, ApiOptions options) + { + return GetAll(repositoryId, new CommitRequest(), options); + } + /// /// Gets all commits for a given repository /// @@ -95,6 +144,19 @@ namespace Octokit return GetAll(owner, name, request, ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// A of s for the specified repository. + public Task> GetAll(int repositoryId, CommitRequest request) + { + Ensure.ArgumentNotNull(request, "request"); + + return GetAll(repositoryId, request, ApiOptions.None); + } + /// /// Gets all commits for a given repository /// @@ -108,10 +170,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); return ApiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } + /// + /// Gets all commits for a given repository + /// + /// The ID of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// A of s for the specified repository. + public Task> GetAll(int repositoryId, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepositoryCommits(repositoryId), request.ToParametersDictionary(), options); + } + /// /// Get the SHA-1 of a commit reference /// @@ -127,5 +205,18 @@ namespace Octokit return ApiConnection.Get(ApiUrls.RepositoryCommit(owner, name, reference), null, AcceptHeaders.CommitReferenceSha1Preview); } + + /// + /// Get the SHA-1 of a commit reference + /// + /// The ID of the repository + /// The repository reference + /// A for the specified repository reference. + public Task GetSha1(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Get(ApiUrls.RepositoryCommit(repositoryId, reference), null, AcceptHeaders.CommitReferenceSha1Preview); + } } } \ No newline at end of file