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>
|
/// <returns></returns>
|
||||||
public IObservable<CompareResult> Compare(string owner, string name, string @base, string head)
|
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>
|
/// <summary>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace Octokit.Tests.Clients
|
|||||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null));
|
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null));
|
||||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create(new NewRepository { Name = null }));
|
await AssertEx.Throws<ArgumentException>(async () => await client.Create(new NewRepository { Name = null }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void UsesTheUserReposUrl()
|
public void UsesTheUserReposUrl()
|
||||||
{
|
{
|
||||||
@@ -345,9 +345,9 @@ namespace Octokit.Tests.Clients
|
|||||||
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
||||||
|
|
||||||
Assert.Equal("README.md", readme.Name);
|
Assert.Equal("README.md", readme.Name);
|
||||||
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
||||||
null);
|
null);
|
||||||
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
||||||
null);
|
null);
|
||||||
var htmlReadme = await readme.GetHtmlContent();
|
var htmlReadme = await readme.GetHtmlContent();
|
||||||
Assert.Equal("<html>README</html>", htmlReadme);
|
Assert.Equal("<html>README</html>", htmlReadme);
|
||||||
@@ -563,7 +563,7 @@ namespace Octokit.Tests.Clients
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void EnsureNonNullArguments()
|
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<ArgumentNullException>(() => client.Compare(null, "repo", "base", "head"));
|
||||||
Assert.Throws<ArgumentException>(() => client.Compare("", "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 connection = Substitute.For<IApiConnection>();
|
||||||
|
|
||||||
var client = new RepositoriesClient(connection);
|
var client = new RepositoryCommitsClient(connection);
|
||||||
|
|
||||||
client.Compare("owner", "repo", "base", "head");
|
client.Compare("owner", "repo", "base", "head");
|
||||||
|
|
||||||
@@ -596,7 +596,7 @@ namespace Octokit.Tests.Clients
|
|||||||
{
|
{
|
||||||
var connection = Substitute.For<IApiConnection>();
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
|
||||||
var client = new RepositoriesClient(connection);
|
var client = new RepositoryCommitsClient(connection);
|
||||||
|
|
||||||
client.Compare("owner", "repo", "base", "shiftkey/my-cool-branch");
|
client.Compare("owner", "repo", "base", "shiftkey/my-cool-branch");
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,14 @@ namespace Octokit
|
|||||||
///</remarks>
|
///</remarks>
|
||||||
IStatisticsClient Statistics { get; }
|
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>
|
/// <summary>
|
||||||
/// Gets all the branches for the specified repository.
|
/// Gets all the branches for the specified repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -264,16 +272,5 @@ namespace Octokit
|
|||||||
/// <param name="update">New values to update the repository with</param>
|
/// <param name="update">New values to update the repository with</param>
|
||||||
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
|
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
|
||||||
Task<Repository> Edit(string owner, string name, RepositoryUpdate update);
|
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);
|
Deployment = new DeploymentsClient(apiConnection);
|
||||||
PullRequest = new PullRequestsClient(apiConnection);
|
PullRequest = new PullRequestsClient(apiConnection);
|
||||||
RepositoryComments = new RepositoryCommentsClient(apiConnection);
|
RepositoryComments = new RepositoryCommentsClient(apiConnection);
|
||||||
|
Commits = new RepositoryCommitsClient(apiConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -279,6 +280,14 @@ namespace Octokit
|
|||||||
///</remarks>
|
///</remarks>
|
||||||
public IStatisticsClient Statistics { get; private set; }
|
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>
|
/// <summary>
|
||||||
/// Client for managing pull requests.
|
/// Client for managing pull requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -426,23 +435,5 @@ namespace Octokit
|
|||||||
|
|
||||||
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, repositoryName, branchName));
|
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\SearchCodeResult.cs" />
|
||||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||||
<Compile Include="Models\Response\CompareResult.cs" />
|
<Compile Include="Models\Response\CompareResult.cs" />
|
||||||
|
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -322,6 +322,8 @@
|
|||||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||||
<Compile Include="Models\Response\CompareResult.cs" />
|
<Compile Include="Models\Response\CompareResult.cs" />
|
||||||
|
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -317,6 +317,8 @@
|
|||||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||||
<Compile Include="Models\Response\CompareResult.cs" />
|
<Compile Include="Models\Response\CompareResult.cs" />
|
||||||
|
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -309,6 +309,8 @@
|
|||||||
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
<Compile Include="Models\Response\SearchCodeResult.cs" />
|
||||||
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
<Compile Include="Models\Response\SearchIssuesResult.cs" />
|
||||||
<Compile Include="Models\Response\CompareResult.cs" />
|
<Compile Include="Models\Response\CompareResult.cs" />
|
||||||
|
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||||
|
|||||||
@@ -53,10 +53,12 @@
|
|||||||
<Link>Properties\SolutionInfo.cs</Link>
|
<Link>Properties\SolutionInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Clients\ActivitiesClient.cs" />
|
<Compile Include="Clients\ActivitiesClient.cs" />
|
||||||
|
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
|
||||||
<Compile Include="Clients\RepositoryCommentsClient.cs" />
|
<Compile Include="Clients\RepositoryCommentsClient.cs" />
|
||||||
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
|
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
|
||||||
<Compile Include="Clients\FeedsClient.cs" />
|
<Compile Include="Clients\FeedsClient.cs" />
|
||||||
<Compile Include="Clients\IFeedsClient.cs" />
|
<Compile Include="Clients\IFeedsClient.cs" />
|
||||||
|
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user