mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-12 06:00:38 +00:00
Moved GetReadme and GetReadmeHtml to Contents
This commit is contained in:
committed by
Haacked
parent
790c07da30
commit
bed18b9980
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
using Octokit.Reactive.Clients;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
@@ -80,6 +79,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
|
||||
IObservable<Readme> GetReadme(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
@@ -88,6 +88,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
|
||||
IObservable<string> GetReadmeHtml(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
@@ -124,6 +125,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
IObservableRepositoryCommentsClient RepositoryComments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Contents API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/">Repository Contents API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryContentsClient Content { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableRepositoryContentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the HTML rendered README.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Readme> GetReadme(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Returns just the HTML portion of the README without the surrounding HTML document.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
IObservable<string> GetReadmeHtml(string owner, string name);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace Octokit.Reactive
|
||||
RepositoryComments = new ObservableRepositoryCommentsClient(client);
|
||||
Commits = new ObservableRepositoryCommitsClient(client);
|
||||
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
|
||||
Content = new ObservableRepositoryContentsClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -135,12 +136,10 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
|
||||
public IObservable<Readme> GetReadme(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.GetReadme(owner, name).ToObservable();
|
||||
return _client.Content.GetReadme(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -149,12 +148,10 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
|
||||
public IObservable<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.GetReadmeHtml(owner, name).ToObservable();
|
||||
return _client.Content.GetReadmeHtml(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -191,6 +188,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
public IObservableRepositoryCommentsClient RepositoryComments { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Contents API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/">Repository Contents API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryContentsClient Content { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableRepositoryContentsClient : IObservableRepositoryContentsClient
|
||||
{
|
||||
readonly IGitHubClient _client;
|
||||
|
||||
public ObservableRepositoryContentsClient(IGitHubClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the HTML rendered README.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Readme> GetReadme(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.Repository.Content.GetReadme(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns just the HTML portion of the README without the surrounding HTML document.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.Repository.Content.GetReadmeHtml(owner, name).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -156,4 +158,4 @@
|
||||
<Name>Octokit-Mono</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -157,6 +157,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -165,4 +167,4 @@
|
||||
<Name>Octokit-MonoAndroid</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -152,6 +152,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -160,4 +162,4 @@
|
||||
<Name>Octokit-Monotouch</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
|
||||
@@ -95,6 +96,7 @@
|
||||
<Compile Include="Clients\ObservableFeedsClient.cs" />
|
||||
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableSearchClient.cs" />
|
||||
<Compile Include="Clients\IObservableBlobsClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistCommentsClient.cs" />
|
||||
@@ -198,4 +200,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -323,54 +323,6 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetReadmeMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsReadme()
|
||||
{
|
||||
string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
|
||||
var readmeInfo = new ReadmeResponse
|
||||
{
|
||||
Content = encodedContent,
|
||||
Encoding = "base64",
|
||||
Name = "README.md",
|
||||
Url = "https://github.example.com/readme.md",
|
||||
HtmlUrl = "https://github.example.com/readme"
|
||||
};
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
connection.Get<ReadmeResponse>(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
|
||||
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
|
||||
var reposEndpoint = new RepositoriesClient(connection);
|
||||
|
||||
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
||||
|
||||
Assert.Equal("README.md", readme.Name);
|
||||
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
||||
null);
|
||||
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"),
|
||||
null);
|
||||
var htmlReadme = await readme.GetHtmlContent();
|
||||
Assert.Equal("<html>README</html>", htmlReadme);
|
||||
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetReadmeHtmlMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsReadmeHtml()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
|
||||
var reposEndpoint = new RepositoriesClient(connection);
|
||||
|
||||
var readme = await reposEndpoint.GetReadmeHtml("fake", "repo");
|
||||
|
||||
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), null);
|
||||
Assert.Equal("<html>README</html>", readme);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllBranchesMethod
|
||||
{
|
||||
[Fact]
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class RepositoryContentsClientTests
|
||||
{
|
||||
public class TheGetReadmeMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsReadme()
|
||||
{
|
||||
string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
|
||||
var readmeInfo = new ReadmeResponse
|
||||
{
|
||||
Content = encodedContent,
|
||||
Encoding = "base64",
|
||||
Name = "README.md",
|
||||
Url = "https://github.example.com/readme.md",
|
||||
HtmlUrl = "https://github.example.com/readme"
|
||||
};
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
connection.Get<ReadmeResponse>(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
|
||||
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
|
||||
var contentsClient = new RepositoryContentsClient(connection);
|
||||
|
||||
var readme = await contentsClient.GetReadme("fake", "repo");
|
||||
|
||||
Assert.Equal("README.md", readme.Name);
|
||||
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
|
||||
null);
|
||||
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
||||
null);
|
||||
var htmlReadme = await readme.GetHtmlContent();
|
||||
Assert.Equal("<html>README</html>", htmlReadme);
|
||||
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetReadmeHtmlMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsReadmeHtml()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
|
||||
var contentsClient = new RepositoryContentsClient(connection);
|
||||
|
||||
var readme = await contentsClient.GetReadmeHtml("fake", "repo");
|
||||
|
||||
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), null);
|
||||
Assert.Equal("<html>README</html>", readme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@
|
||||
<Compile Include="Clients\DeploymentStatusClientTests.cs" />
|
||||
<Compile Include="Clients\FeedsClientTests.cs" />
|
||||
<Compile Include="Clients\RepositoryDeployKeysClientTests.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClientTests.cs" />
|
||||
<Compile Include="Clients\SearchClientTests.cs" />
|
||||
<Compile Include="Clients\GistCommentsClientTests.cs" />
|
||||
<Compile Include="Clients\GistsClientTests.cs" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
#if NET_45
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
@@ -38,6 +39,14 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
IRepositoryDeployKeysClient DeployKeys { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing the contents of a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/">Repository Contents API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IRepositoryContentsClient Content { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new repository for the current user.
|
||||
/// </summary>
|
||||
@@ -136,6 +145,7 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
|
||||
Task<Readme> GetReadme(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
@@ -148,6 +158,7 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
|
||||
Task<string> GetReadmeHtml(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IRepositoryContentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the preferred README for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
Task<Readme> GetReadme(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the perferred README's HTML for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
Task<string> GetReadmeHtml(string owner, string name);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ namespace Octokit
|
||||
RepositoryComments = new RepositoryCommentsClient(apiConnection);
|
||||
Commits = new RepositoryCommitsClient(apiConnection);
|
||||
DeployKeys = new RepositoryDeployKeysClient(apiConnection);
|
||||
Content = new RepositoryContentsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -215,14 +216,10 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public async Task<Readme> GetReadme(string owner, string name)
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
|
||||
public Task<Readme> GetReadme(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name);
|
||||
var readmeInfo = await ApiConnection.Get<ReadmeResponse>(endpoint, null).ConfigureAwait(false);
|
||||
return new Readme(readmeInfo, ApiConnection);
|
||||
return Content.GetReadme(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,13 +232,10 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
|
||||
public Task<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name);
|
||||
return ApiConnection.GetHtml(endpoint, null);
|
||||
return Content.GetReadmeHtml(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -310,6 +304,14 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
public IRepositoryDeployKeysClient DeployKeys { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing the contents of a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/">Repository Contents API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IRepositoryContentsClient Content { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class RepositoryContentsClient : ApiClient, IRepositoryContentsClient
|
||||
{
|
||||
public RepositoryContentsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preferred README for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public async Task<Readme> GetReadme(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = ApiUrls.RepositoryReadme(owner, name);
|
||||
var readmeInfo = await ApiConnection.Get<ReadmeResponse>(endpoint, null).ConfigureAwait(false);
|
||||
|
||||
return new Readme(readmeInfo, ApiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the perferred README's HTML for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetHtml(ApiUrls.RepositoryReadme(owner, name), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1345,5 +1345,16 @@ namespace Octokit
|
||||
{
|
||||
return _oauthAccesToken;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for getting the README of the specified repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns>The <see cref="Uri"/> for getting the README of the specified repository</returns>
|
||||
public static Uri RepositoryReadme(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/readme".FormatUri(owner, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace Octokit
|
||||
public interface IGitHubClient
|
||||
{
|
||||
IConnection Connection { get; }
|
||||
|
||||
IAuthorizationsClient Authorization { get; }
|
||||
IActivitiesClient Activity { get; }
|
||||
IIssuesClient Issue { get; }
|
||||
|
||||
@@ -347,6 +347,8 @@
|
||||
<Compile Include="Models\Response\ThreadSubscription.cs" />
|
||||
<Compile Include="Models\Request\MarkAsReadRequest.cs" />
|
||||
<Compile Include="Models\Request\NewThreadSubscription.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -357,6 +357,8 @@
|
||||
<Compile Include="Models\Response\ThreadSubscription.cs" />
|
||||
<Compile Include="Models\Request\MarkAsReadRequest.cs" />
|
||||
<Compile Include="Models\Request\NewThreadSubscription.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -352,6 +352,9 @@
|
||||
<Compile Include="Models\Response\ThreadSubscription.cs" />
|
||||
<Compile Include="Models\Request\MarkAsReadRequest.cs" />
|
||||
<Compile Include="Models\Request\NewThreadSubscription.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
||||
</Project>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
<Compile Include="Clients\IPullRequestsClient.cs" />
|
||||
<Compile Include="Clients\IReleasesClient.cs" />
|
||||
<Compile Include="Clients\IRepositoriesClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ISshKeysClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
@@ -106,6 +107,7 @@
|
||||
<Compile Include="Clients\PullRequestsClient.cs" />
|
||||
<Compile Include="Clients\ReleasesClient.cs" />
|
||||
<Compile Include="Clients\RepositoriesClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\SshKeysClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Clients\StatisticsClient.cs" />
|
||||
@@ -375,4 +377,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -349,6 +349,8 @@
|
||||
<Compile Include="Models\Response\ThreadSubscription.cs" />
|
||||
<Compile Include="Models\Request\MarkAsReadRequest.cs" />
|
||||
<Compile Include="Models\Request\NewThreadSubscription.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IUserKeysClient.cs" />
|
||||
<Compile Include="Clients\OAuthClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\FeedsClient.cs" />
|
||||
@@ -67,6 +68,7 @@
|
||||
<Compile Include="Clients\RepositoryCommitsClient.cs" />
|
||||
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\UserKeysClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||
@@ -387,4 +389,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user