Moved GetReadme and GetReadmeHtml to Contents

This commit is contained in:
Kristian Hellang
2014-03-18 20:12:13 +01:00
committed by Haacked
parent 790c07da30
commit bed18b9980
23 changed files with 295 additions and 78 deletions
@@ -1,7 +1,6 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reactive; using System.Reactive;
using Octokit.Reactive.Clients;
namespace Octokit.Reactive namespace Octokit.Reactive
{ {
@@ -80,6 +79,7 @@ namespace Octokit.Reactive
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
IObservable<Readme> GetReadme(string owner, string name); IObservable<Readme> GetReadme(string owner, string name);
/// <summary> /// <summary>
@@ -88,6 +88,7 @@ namespace Octokit.Reactive
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
IObservable<string> GetReadmeHtml(string owner, string name); IObservable<string> GetReadmeHtml(string owner, string name);
/// <summary> /// <summary>
@@ -124,6 +125,14 @@ namespace Octokit.Reactive
/// </remarks> /// </remarks>
IObservableRepositoryCommentsClient RepositoryComments { get; } 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> /// <summary>
/// Gets all the branches for the specified repository. /// Gets all the branches for the specified repository.
/// </summary> /// </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); RepositoryComments = new ObservableRepositoryCommentsClient(client);
Commits = new ObservableRepositoryCommitsClient(client); Commits = new ObservableRepositoryCommitsClient(client);
DeployKeys = new ObservableRepositoryDeployKeysClient(client); DeployKeys = new ObservableRepositoryDeployKeysClient(client);
Content = new ObservableRepositoryContentsClient(client);
} }
/// <summary> /// <summary>
@@ -135,12 +136,10 @@ namespace Octokit.Reactive
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
public IObservable<Readme> GetReadme(string owner, string name) public IObservable<Readme> GetReadme(string owner, string name)
{ {
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); return _client.Content.GetReadme(owner, name).ToObservable();
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.GetReadme(owner, name).ToObservable();
} }
/// <summary> /// <summary>
@@ -149,12 +148,10 @@ namespace Octokit.Reactive
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
public IObservable<string> GetReadmeHtml(string owner, string name) public IObservable<string> GetReadmeHtml(string owner, string name)
{ {
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); return _client.Content.GetReadmeHtml(owner, name).ToObservable();
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.GetReadmeHtml(owner, name).ToObservable();
} }
/// <summary> /// <summary>
@@ -191,6 +188,14 @@ namespace Octokit.Reactive
/// </remarks> /// </remarks>
public IObservableRepositoryCommentsClient RepositoryComments { get; private set; } 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> /// <summary>
/// Gets all the branches for the specified repository. /// Gets all the branches for the specified repository.
/// </summary> /// </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\ObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IObservableUserKeysClient.cs" /> <Compile Include="Clients\IObservableUserKeysClient.cs" />
<Compile Include="Clients\ObservableUserKeysClient.cs" /> <Compile Include="Clients\ObservableUserKeysClient.cs" />
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
@@ -156,4 +158,4 @@
<Name>Octokit-Mono</Name> <Name>Octokit-Mono</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -157,6 +157,8 @@
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" /> <Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IObservableUserKeysClient.cs" /> <Compile Include="Clients\IObservableUserKeysClient.cs" />
<Compile Include="Clients\ObservableUserKeysClient.cs" /> <Compile Include="Clients\ObservableUserKeysClient.cs" />
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup> <ItemGroup>
@@ -165,4 +167,4 @@
<Name>Octokit-MonoAndroid</Name> <Name>Octokit-MonoAndroid</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -152,6 +152,8 @@
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" /> <Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IObservableUserKeysClient.cs" /> <Compile Include="Clients\IObservableUserKeysClient.cs" />
<Compile Include="Clients\ObservableUserKeysClient.cs" /> <Compile Include="Clients\ObservableUserKeysClient.cs" />
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
@@ -160,4 +162,4 @@
<Name>Octokit-Monotouch</Name> <Name>Octokit-Monotouch</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
</Project> </Project>
+3 -1
View File
@@ -80,6 +80,7 @@
<Compile Include="Clients\IObservableUserKeysClient.cs" /> <Compile Include="Clients\IObservableUserKeysClient.cs" />
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" /> <Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\ObservableOauthClient.cs" /> <Compile Include="Clients\ObservableOauthClient.cs" />
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" /> <Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" /> <Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
<Compile Include="Clients\IObservableDeploymentsClient.cs" /> <Compile Include="Clients\IObservableDeploymentsClient.cs" />
@@ -95,6 +96,7 @@
<Compile Include="Clients\ObservableFeedsClient.cs" /> <Compile Include="Clients\ObservableFeedsClient.cs" />
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" /> <Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommitsClients.cs" /> <Compile Include="Clients\ObservableRepositoryCommitsClients.cs" />
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableSearchClient.cs" /> <Compile Include="Clients\ObservableSearchClient.cs" />
<Compile Include="Clients\IObservableBlobsClient.cs" /> <Compile Include="Clients\IObservableBlobsClient.cs" />
<Compile Include="Clients\IObservableGistCommentsClient.cs" /> <Compile Include="Clients\IObservableGistCommentsClient.cs" />
@@ -198,4 +200,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </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 public class TheGetAllBranchesMethod
{ {
[Fact] [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);
}
}
}
}
+1
View File
@@ -75,6 +75,7 @@
<Compile Include="Clients\DeploymentStatusClientTests.cs" /> <Compile Include="Clients\DeploymentStatusClientTests.cs" />
<Compile Include="Clients\FeedsClientTests.cs" /> <Compile Include="Clients\FeedsClientTests.cs" />
<Compile Include="Clients\RepositoryDeployKeysClientTests.cs" /> <Compile Include="Clients\RepositoryDeployKeysClientTests.cs" />
<Compile Include="Clients\RepositoryContentsClientTests.cs" />
<Compile Include="Clients\SearchClientTests.cs" /> <Compile Include="Clients\SearchClientTests.cs" />
<Compile Include="Clients\GistCommentsClientTests.cs" /> <Compile Include="Clients\GistCommentsClientTests.cs" />
<Compile Include="Clients\GistsClientTests.cs" /> <Compile Include="Clients\GistsClientTests.cs" />
+11
View File
@@ -1,3 +1,4 @@
using System;
#if NET_45 #if NET_45
using System.Collections.Generic; using System.Collections.Generic;
#endif #endif
@@ -38,6 +39,14 @@ namespace Octokit
/// </remarks> /// </remarks>
IRepositoryDeployKeysClient DeployKeys { get; } 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> /// <summary>
/// Creates a new repository for the current user. /// Creates a new repository for the current user.
/// </summary> /// </summary>
@@ -136,6 +145,7 @@ namespace Octokit
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadme. Please use that instead.")]
Task<Readme> GetReadme(string owner, string name); Task<Readme> GetReadme(string owner, string name);
/// <summary> /// <summary>
@@ -148,6 +158,7 @@ namespace Octokit
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
Task<string> GetReadmeHtml(string owner, string name); Task<string> GetReadmeHtml(string owner, string name);
/// <summary> /// <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);
}
}
+14 -12
View File
@@ -30,6 +30,7 @@ namespace Octokit
RepositoryComments = new RepositoryCommentsClient(apiConnection); RepositoryComments = new RepositoryCommentsClient(apiConnection);
Commits = new RepositoryCommitsClient(apiConnection); Commits = new RepositoryCommitsClient(apiConnection);
DeployKeys = new RepositoryDeployKeysClient(apiConnection); DeployKeys = new RepositoryDeployKeysClient(apiConnection);
Content = new RepositoryContentsClient(apiConnection);
} }
/// <summary> /// <summary>
@@ -215,14 +216,10 @@ namespace Octokit
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns> /// <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"); return Content.GetReadme(owner, name);
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);
} }
/// <summary> /// <summary>
@@ -235,13 +232,10 @@ namespace Octokit
/// <param name="name">The name of the repository</param> /// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns> /// <returns></returns>
[Obsolete("This method has been obsoleted by Contents.GetReadmeHtml. Please use that instead.")]
public Task<string> GetReadmeHtml(string owner, string name) public Task<string> GetReadmeHtml(string owner, string name)
{ {
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); return Content.GetReadmeHtml(owner, name);
Ensure.ArgumentNotNullOrEmptyString(name, "name");
var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name);
return ApiConnection.GetHtml(endpoint, null);
} }
/// <summary> /// <summary>
@@ -310,6 +304,14 @@ namespace Octokit
/// </remarks> /// </remarks>
public IRepositoryDeployKeysClient DeployKeys { get; private set; } 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> /// <summary>
/// Gets all the branches for the specified repository. /// Gets all the branches for the specified repository.
/// </summary> /// </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);
}
}
}
+11
View File
@@ -1345,5 +1345,16 @@ namespace Octokit
{ {
return _oauthAccesToken; 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);
}
} }
} }
-1
View File
@@ -8,7 +8,6 @@ namespace Octokit
public interface IGitHubClient public interface IGitHubClient
{ {
IConnection Connection { get; } IConnection Connection { get; }
IAuthorizationsClient Authorization { get; } IAuthorizationsClient Authorization { get; }
IActivitiesClient Activity { get; } IActivitiesClient Activity { get; }
IIssuesClient Issue { get; } IIssuesClient Issue { get; }
+3 -1
View File
@@ -347,6 +347,8 @@
<Compile Include="Models\Response\ThreadSubscription.cs" /> <Compile Include="Models\Response\ThreadSubscription.cs" />
<Compile Include="Models\Request\MarkAsReadRequest.cs" /> <Compile Include="Models\Request\MarkAsReadRequest.cs" />
<Compile Include="Models\Request\NewThreadSubscription.cs" /> <Compile Include="Models\Request\NewThreadSubscription.cs" />
<Compile Include="Clients\IRepositoryContentsClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>
+2
View File
@@ -357,6 +357,8 @@
<Compile Include="Models\Response\ThreadSubscription.cs" /> <Compile Include="Models\Response\ThreadSubscription.cs" />
<Compile Include="Models\Request\MarkAsReadRequest.cs" /> <Compile Include="Models\Request\MarkAsReadRequest.cs" />
<Compile Include="Models\Request\NewThreadSubscription.cs" /> <Compile Include="Models\Request\NewThreadSubscription.cs" />
<Compile Include="Clients\IRepositoryContentsClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
</Project> </Project>
+4 -1
View File
@@ -352,6 +352,9 @@
<Compile Include="Models\Response\ThreadSubscription.cs" /> <Compile Include="Models\Response\ThreadSubscription.cs" />
<Compile Include="Models\Request\MarkAsReadRequest.cs" /> <Compile Include="Models\Request\MarkAsReadRequest.cs" />
<Compile Include="Models\Request\NewThreadSubscription.cs" /> <Compile Include="Models\Request\NewThreadSubscription.cs" />
<Compile Include="Clients\IRepositoryContentsClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
</Project> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
+3 -1
View File
@@ -85,6 +85,7 @@
<Compile Include="Clients\IPullRequestsClient.cs" /> <Compile Include="Clients\IPullRequestsClient.cs" />
<Compile Include="Clients\IReleasesClient.cs" /> <Compile Include="Clients\IReleasesClient.cs" />
<Compile Include="Clients\IRepositoriesClient.cs" /> <Compile Include="Clients\IRepositoriesClient.cs" />
<Compile Include="Clients\IRepositoryContentsClient.cs" />
<Compile Include="Clients\ISshKeysClient.cs" /> <Compile Include="Clients\ISshKeysClient.cs" />
<Compile Include="Clients\IssueCommentsClient.cs" /> <Compile Include="Clients\IssueCommentsClient.cs" />
<Compile Include="Clients\IssuesClient.cs" /> <Compile Include="Clients\IssuesClient.cs" />
@@ -106,6 +107,7 @@
<Compile Include="Clients\PullRequestsClient.cs" /> <Compile Include="Clients\PullRequestsClient.cs" />
<Compile Include="Clients\ReleasesClient.cs" /> <Compile Include="Clients\ReleasesClient.cs" />
<Compile Include="Clients\RepositoriesClient.cs" /> <Compile Include="Clients\RepositoriesClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.cs" />
<Compile Include="Clients\SshKeysClient.cs" /> <Compile Include="Clients\SshKeysClient.cs" />
<Compile Include="Clients\StarredClient.cs" /> <Compile Include="Clients\StarredClient.cs" />
<Compile Include="Clients\StatisticsClient.cs" /> <Compile Include="Clients\StatisticsClient.cs" />
@@ -375,4 +377,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
+2
View File
@@ -349,6 +349,8 @@
<Compile Include="Models\Response\ThreadSubscription.cs" /> <Compile Include="Models\Response\ThreadSubscription.cs" />
<Compile Include="Models\Request\MarkAsReadRequest.cs" /> <Compile Include="Models\Request\MarkAsReadRequest.cs" />
<Compile Include="Models\Request\NewThreadSubscription.cs" /> <Compile Include="Models\Request\NewThreadSubscription.cs" />
<Compile Include="Clients\IRepositoryContentsClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CodeAnalysisDictionary Include="..\CustomDictionary.xml"> <CodeAnalysisDictionary Include="..\CustomDictionary.xml">
+3 -1
View File
@@ -60,6 +60,7 @@
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" /> <Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IUserKeysClient.cs" /> <Compile Include="Clients\IUserKeysClient.cs" />
<Compile Include="Clients\OAuthClient.cs" /> <Compile Include="Clients\OAuthClient.cs" />
<Compile Include="Clients\IRepositoryContentsClient.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" />
@@ -67,6 +68,7 @@
<Compile Include="Clients\RepositoryCommitsClient.cs" /> <Compile Include="Clients\RepositoryCommitsClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" /> <Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Clients\UserKeysClient.cs" /> <Compile Include="Clients\UserKeysClient.cs" />
<Compile Include="Clients\RepositoryContentsClient.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" />
@@ -387,4 +389,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>