Merge pull request #957 from octokit/clean-up-some-fixes

clean up some pending PRs
This commit is contained in:
Brendan Forster
2015-11-03 12:06:25 -08:00
16 changed files with 275 additions and 11 deletions
@@ -14,6 +14,14 @@ namespace Octokit.Reactive
Justification = "Makes a network request")]
IObservable<Emoji> GetAllEmojis();
/// <summary>
/// Gets the rendered Markdown for an arbitrary markdown document.
/// </summary>
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown);
/// <summary>
/// Gets the rendered Markdown for the specified plain-text Markdown document.
/// </summary>
@@ -26,6 +26,17 @@ namespace Octokit.Reactive
return _client.GetAllEmojis().ToObservable().SelectMany(e => e);
}
/// <summary>
/// Gets the rendered Markdown for an arbitrary markdown document.
/// </summary>
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
public IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown)
{
return _client.RenderArbitraryMarkdown(markdown).ToObservable();
}
/// <summary>
/// Gets the rendered Markdown for the specified plain-text Markdown document.
/// </summary>
@@ -31,7 +31,27 @@ namespace Octokit.Tests.Clients
"text/plain");
}
}
public class TheRenderArbitrryMarkdownMethod
{
[Fact]
public async Task RequestsTheEmojiEndpoint()
{
IApiResponse<string> response = new ApiResponse<string>(new Response(), "<strong>Test</strong>");
var connection = Substitute.For<IConnection>();
var forTest = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext");
connection.Post<string>(Args.Uri,forTest, "text/html", "text/plain")
.Returns(Task.FromResult(response));
var client = new MiscellaneousClient(connection);
var html = await client.RenderArbitraryMarkdown(forTest);
Assert.Equal("<strong>Test</strong>", html);
connection.Received()
.Post<string>(Arg.Is<Uri>(u => u.ToString() == "markdown"),
forTest,
"text/html",
"text/plain");
}
}
public class TheGetEmojisMethod
{
[Fact]
@@ -1046,6 +1046,81 @@ namespace Octokit.Tests.Clients
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+created:2014-01-01..2014-02-02"));
}
[Fact]
public void TestingTheMergedQualifier_GreaterThan()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Merged = DateRange.GreaterThan(new DateTime(2014, 1, 1));
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>2014-01-01"));
}
[Fact]
public void TestingTheMergedQualifier_GreaterThanOrEquals()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Merged = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1));
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:>=2014-01-01"));
}
[Fact]
public void TestingTheMergedQualifier_LessThan()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Merged = DateRange.LessThan(new DateTime(2014, 1, 1));
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<2014-01-01"));
}
[Fact]
public void TestingTheMergedQualifier_LessThanOrEquals()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Merged = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1));
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:<=2014-01-01"));
}
[Fact]
public void TestingTheMergedQualifier_Between()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Merged = DateRange.Between(new DateTime(2014, 1, 1), new DateTime(2014, 2, 2));
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+merged:2014-01-01..2014-02-02"));
}
[Fact]
public void TestingTheUpdatedQualifier_GreaterThan()
{
+8
View File
@@ -30,6 +30,14 @@ namespace Octokit
/// <returns>The rendered Markdown.</returns>
Task<string> RenderRawMarkdown(string markdown);
/// <summary>
/// Gets the rendered Markdown for an arbitrary markdown document.
/// </summary>
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown);
/// <summary>
/// List all templates available to pass as an option when creating a repository.
/// </summary>
+14
View File
@@ -58,6 +58,20 @@ namespace Octokit
return response.Body;
}
/// <summary>
/// Gets the rendered Markdown for an arbitrary markdown document.
/// </summary>
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
public async Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown)
{
var endpoint = new Uri("markdown", UriKind.Relative);
var response = await _connection.Post<string>(endpoint, markdown, "text/html", "text/plain")
.ConfigureAwait(false);
return response.Body;
}
/// <summary>
/// List all templates available to pass as an option when creating a repository.
/// </summary>
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace Octokit
{
/// <summary>
/// Used to create anarbitrary markdown
/// </summary>
/// <remarks>
/// API: https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
/// </remarks>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewArbitraryMarkdown
{
const string _markdown = "markdown";
const string _gfm = "gfm";
/// <summary>
/// Create an arbitrary markdown
/// </summary>
/// <param name="text">The Markdown text to render</param>
/// <param name="mode">The rendering mode. Can be either markdown by default or gfm</param>
/// <param name="context">
/// The repository context. Only taken into account when rendering as gfm
/// </param>
public NewArbitraryMarkdown(string text, string mode, string context)
{
Text = text;
Mode = GetMode(mode);
Context = context;
}
/// <summary>
/// Create an arbitrary markdown
/// </summary>
/// <param name="text">The Markdown text to render
/// </param>
public NewArbitraryMarkdown(string text)
:this(text,_markdown,null)
{
}
/// <summary>
/// Create an arbitrary markdown
/// </summary>
/// <param name="text">The Markdown text to render</param>
/// <param name="mode">The rendering mode. Can be either markdown by default or gfm</param>
/// </param>
public NewArbitraryMarkdown(string text, string mode)
: this(text, mode, null)
{
}
/// <summary>
/// Gets the markdown text
/// </summary>
/// <value>
/// The text.
/// </value>
public string Text { get; private set; }
/// <summary>
/// Gets the mode of the text
/// </summary>
/// <value>
/// The mode.
/// </value>
public string Mode { get; private set; }
/// <summary>
/// Gets the context of the markdown
/// </summary>
/// <value>
/// The context.
/// </value>
public string Context { get; private set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "gfm")]
static string GetMode(string mode)
{
if (mode != _markdown && mode != _gfm)
{
throw (new FormatException("The mode must be either 'markdown' or 'gfm'"));
}
else
return mode;
}
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Text: {0}", Text);
}
}
}
}
+19 -3
View File
@@ -43,7 +43,7 @@ namespace Octokit
}
/// <summary>
/// Optional Sort field. One of comments, created, or updated.
/// Optional Sort field. One of comments, created, updated or merged
/// If not provided, results are sorted by best match.
/// </summary>
/// <remarks>
@@ -177,6 +177,13 @@ namespace Octokit
/// </remarks>
public DateRange Updated { get; set; }
/// <summary>
/// Filters issues based on times when they were last merged
/// </summary>
/// <remarks>
/// https://help.github.com/articles/searching-issues/#search-based-on-when-a-pull-request-was-merged
/// </remarks>
public DateRange Merged { get; set; }
/// <summary>
/// Filters issues based on the quantity of comments.
/// </summary>
@@ -196,6 +203,7 @@ namespace Octokit
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public RepositoryCollection Repos { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public override IReadOnlyList<string> MergedQualifiers()
{
var parameters = new List<string>();
@@ -261,7 +269,10 @@ namespace Octokit
{
parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
}
if (Merged != null)
{
parameters.Add(String.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged));
}
if (Comments != null)
{
parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
@@ -312,7 +323,12 @@ namespace Octokit
/// search by last updated
/// </summary>
[Parameter(Value = "updated")]
Updated
Updated,
/// <summary>
/// search by last merged
/// </summary>
[Parameter(Value = "merged")]
Merged
}
public enum IssueInQualifier
+7 -1
View File
@@ -14,7 +14,7 @@ namespace Octokit
Number = number;
}
public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, string mergeCommitSha, bool merged, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles)
public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, string mergeCommitSha, bool merged, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles)
{
Url = url;
HtmlUrl = htmlUrl;
@@ -33,6 +33,7 @@ namespace Octokit
Head = head;
Base = @base;
User = user;
Assignee = assignee;
MergeCommitSha = mergeCommitSha;
Merged = merged;
Mergeable = mergeable;
@@ -129,6 +130,11 @@ namespace Octokit
/// </summary>
public User User { get; protected set; }
/// <summary>
/// The user who is assigned the pull request.
/// </summary>
public User Assignee { get; protected set; }
/// <summary>
/// The SHA of the merge commit.
/// </summary>
+2 -1
View File
@@ -104,6 +104,7 @@
<Compile Include="Models\Request\LabelUpdate.cs" />
<Compile Include="Models\Request\MergePullRequest.cs" />
<Compile Include="Models\Request\MilestoneUpdate.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
<Compile Include="Models\Request\NewBlob.cs" />
<Compile Include="Models\Request\NewCommit.cs" />
<Compile Include="Models\Request\NewCommitStatus.cs" />
@@ -405,4 +406,4 @@
<Compile Include="Models\Common\Committer.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
+1
View File
@@ -411,6 +411,7 @@
<Compile Include="Http\IApiInfoProvider.cs" />
<Compile Include="Models\Response\Meta.cs" />
<Compile Include="Models\Common\Committer.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
</Project>
+2 -1
View File
@@ -407,7 +407,8 @@
<Compile Include="Http\IApiInfoProvider.cs" />
<Compile Include="Models\Response\Meta.cs" />
<Compile Include="Models\Common\Committer.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
+2 -1
View File
@@ -184,6 +184,7 @@
<Compile Include="Models\Request\MergePullRequest.cs" />
<Compile Include="Models\Request\MilestoneRequest.cs" />
<Compile Include="Models\Request\MilestoneUpdate.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
<Compile Include="Models\Request\NewAuthorization.cs" />
<Compile Include="Models\Request\NewBlob.cs" />
<Compile Include="Models\Request\NewCommit.cs" />
@@ -430,4 +431,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
+1
View File
@@ -404,6 +404,7 @@
<Compile Include="Http\IApiInfoProvider.cs" />
<Compile Include="Models\Response\Meta.cs" />
<Compile Include="Models\Common\Committer.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
+2 -1
View File
@@ -87,6 +87,7 @@
<Compile Include="Http\ProductHeaderValue.cs" />
<Compile Include="Http\RequestBody.cs" />
<Compile Include="Models\Request\GistFileUpdate.cs" />
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
<Compile Include="Models\Request\NewMerge.cs" />
<Compile Include="Models\Request\PublicRepositoryRequest.cs" />
<Compile Include="Models\Request\ReleaseAssetUpload.cs" />
@@ -441,4 +442,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
+3 -3
View File
@@ -3,11 +3,11 @@ using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyProductAttribute("Octokit")]
[assembly: AssemblyVersionAttribute("0.16.0")]
[assembly: AssemblyFileVersionAttribute("0.16.0")]
[assembly: AssemblyVersionAttribute("0.17.0")]
[assembly: AssemblyFileVersionAttribute("0.17.0")]
[assembly: ComVisibleAttribute(false)]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "0.16.0";
internal const string Version = "0.17.0";
}
}