mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 21:55:12 +00:00
moved function out to separate client
This commit is contained in:
@@ -338,7 +338,7 @@ namespace Octokit.Reactive
|
||||
/// <returns></returns>
|
||||
public IObservable<CompareResult> Compare(string owner, string name, string @base, string head)
|
||||
{
|
||||
return _client.Compare(owner, name, @base, head).ToObservable();
|
||||
return _client.Commits.Compare(owner, name, @base, head).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -563,7 +563,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public void EnsureNonNullArguments()
|
||||
{
|
||||
var client = new RepositoriesClient(Substitute.For<IApiConnection>());
|
||||
var client = new RepositoryCommitsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Compare(null, "repo", "base", "head"));
|
||||
Assert.Throws<ArgumentException>(() => client.Compare("", "repo", "base", "head"));
|
||||
@@ -583,7 +583,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
|
||||
var client = new RepositoriesClient(connection);
|
||||
var client = new RepositoryCommitsClient(connection);
|
||||
|
||||
client.Compare("owner", "repo", "base", "head");
|
||||
|
||||
@@ -596,7 +596,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
|
||||
var client = new RepositoriesClient(connection);
|
||||
var client = new RepositoryCommitsClient(connection);
|
||||
|
||||
client.Compare("owner", "repo", "base", "shiftkey/my-cool-branch");
|
||||
|
||||
|
||||
@@ -176,6 +176,14 @@ namespace Octokit
|
||||
///</remarks>
|
||||
IStatisticsClient Statistics { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
IRepositoryCommitsClient Commits { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
@@ -264,16 +272,5 @@ namespace Octokit
|
||||
/// <param name="update">New values to update the repository with</param>
|
||||
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
|
||||
Task<Repository> Edit(string owner, string name, RepositoryUpdate update);
|
||||
|
||||
/// <summary>
|
||||
/// Compare two references in a repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="base">The reference to use as the base commit</param>
|
||||
/// <param name="head">The reference to use as the head commit</param>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")]
|
||||
Task<CompareResult> Compare(string owner, string name, string @base, string head);
|
||||
}
|
||||
}
|
||||
|
||||
19
Octokit/Clients/IRepositoryCommitsClient.cs
Normal file
19
Octokit/Clients/IRepositoryCommitsClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IRepositoryCommitsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Compare two references in a repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="base">The reference to use as the base commit</param>
|
||||
/// <param name="head">The reference to use as the head commit</param>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")]
|
||||
Task<CompareResult> Compare(string owner, string name, string @base, string head);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace Octokit
|
||||
Deployment = new DeploymentsClient(apiConnection);
|
||||
PullRequest = new PullRequestsClient(apiConnection);
|
||||
RepositoryComments = new RepositoryCommentsClient(apiConnection);
|
||||
Commits = new RepositoryCommitsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -279,6 +280,14 @@ namespace Octokit
|
||||
///</remarks>
|
||||
public IStatisticsClient Statistics { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
public IRepositoryCommitsClient Commits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing pull requests.
|
||||
/// </summary>
|
||||
@@ -426,23 +435,5 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, repositoryName, branchName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two references in a repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="base">The reference to use as the base commit</param>
|
||||
/// <param name="head">The reference to use as the head commit</param>
|
||||
/// <returns></returns>
|
||||
public Task<CompareResult> Compare(string owner, string name, string @base, string head)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "repositoryName");
|
||||
Ensure.ArgumentNotNullOrEmptyString(@base, "base");
|
||||
Ensure.ArgumentNotNullOrEmptyString(head, "head");
|
||||
|
||||
return ApiConnection.Get<CompareResult>(ApiUrls.RepoCompare(owner, name, @base, head));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
Octokit/Clients/RepositoryCommitsClient.cs
Normal file
24
Octokit/Clients/RepositoryCommitsClient.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class RepositoryCommitsClient : IRepositoryCommitsClient
|
||||
{
|
||||
readonly IApiConnection _apiConnection;
|
||||
|
||||
public RepositoryCommitsClient(IApiConnection apiConnection)
|
||||
{
|
||||
_apiConnection = apiConnection;
|
||||
}
|
||||
|
||||
public Task<CompareResult> Compare(string owner, string name, string @base, string head)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "repositoryName");
|
||||
Ensure.ArgumentNotNullOrEmptyString(@base, "base");
|
||||
Ensure.ArgumentNotNullOrEmptyString(head, "head");
|
||||
|
||||
return _apiConnection.Get<CompareResult>(ApiUrls.RepoCompare(owner, name, @base, head));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,6 +311,8 @@
|
||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||
<Compile Include="Models\Response\CompareResult.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -322,6 +322,8 @@
|
||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||
<Compile Include="Models\Response\CompareResult.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -317,6 +317,8 @@
|
||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||
<Compile Include="Models\Response\CompareResult.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -309,6 +309,8 @@
|
||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||
<Compile Include="Models\Response\CompareResult.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -53,10 +53,12 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\ActivitiesClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\FeedsClient.cs" />
|
||||
<Compile Include="Clients\IFeedsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user