diff --git a/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs
new file mode 100644
index 00000000..0ff8beb2
--- /dev/null
+++ b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace Octokit.Reactive
+{
+ public interface IObservableCommitStatusClient
+ {
+ ///
+ /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
+ /// a tag name.
+ ///
+ /// Only users with pull access can see this.
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ ///
+ IObservable GetAll(string owner, string name, string reference);
+
+ ///
+ /// Creates a commit status for the specified ref.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ /// The commit status to create.
+ ///
+ IObservable Create(string owner, string name, string reference, NewCommitStatus commitStatus);
+ }
+}
diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
index 88059b19..75a084fd 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
@@ -88,5 +88,15 @@ namespace Octokit.Reactive
/// The name of the repository.
///
IObservable GetReadmeHtml(string owner, string name);
+
+ ///
+ /// A client for GitHub's Commit Status API.
+ ///
+ ///
+ /// See the Commit Status API documentation for more
+ /// details. Also check out the blog post
+ /// that announced this feature.
+ ///
+ IObservableCommitStatusClient CommitStatus { get; }
}
}
diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs
new file mode 100644
index 00000000..a1d35f14
--- /dev/null
+++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Reactive.Threading.Tasks;
+using Octokit.Reactive.Internal;
+
+namespace Octokit.Reactive
+{
+ public class ObservableCommitStatusClient : IObservableCommitStatusClient
+ {
+ readonly ICommitStatusClient _client;
+ readonly IConnection _connection;
+
+ public ObservableCommitStatusClient(IGitHubClient client)
+ {
+ Ensure.ArgumentNotNull(client, "client");
+
+ _client = client.Repository.CommitStatus;
+ _connection = client.Connection;
+ }
+
+ ///
+ /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
+ /// a tag name.
+ ///
+ /// Only users with pull access can see this.
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ ///
+ public IObservable GetAll(string owner, string name, string reference)
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatus(owner, name, reference));
+ }
+
+ ///
+ /// Creates a commit status for the specified ref.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ /// The commit status to create.
+ ///
+ public IObservable Create(string owner, string name, string reference, NewCommitStatus commitStatus)
+ {
+ return _client.Create(owner, name, reference, commitStatus).ToObservable();
+ }
+ }
+}
diff --git a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
index 621c0c62..1db9f492 100644
--- a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
@@ -9,7 +9,6 @@ namespace Octokit.Reactive
readonly IOrganizationsClient _client;
readonly IConnection _connection;
-
public ObservableOrganizationsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
index a6ff5115..05d60706 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
@@ -16,6 +16,7 @@ namespace Octokit.Reactive
_client = client.Repository;
_connection = client.Connection;
+ CommitStatus = new ObservableCommitStatusClient(client);
}
///
@@ -105,5 +106,7 @@ namespace Octokit.Reactive
return _client.GetReadmeHtml(owner, name).ToObservable();
}
+
+ public IObservableCommitStatusClient CommitStatus { get; private set; }
}
}
diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj
index 122911d3..37dd880e 100644
--- a/Octokit.Reactive/Octokit.Reactive.csproj
+++ b/Octokit.Reactive/Octokit.Reactive.csproj
@@ -85,6 +85,8 @@
Properties\SolutionInfo.cs
+
+
diff --git a/Octokit.Tests.Integration/CommitStatusClientTests.cs b/Octokit.Tests.Integration/CommitStatusClientTests.cs
new file mode 100644
index 00000000..5f7de7f6
--- /dev/null
+++ b/Octokit.Tests.Integration/CommitStatusClientTests.cs
@@ -0,0 +1,31 @@
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Octokit.Tests.Integration
+{
+ public class CommitStatusClientTests
+ {
+ public class TheGetAllMethod
+ {
+ [IntegrationTest]
+ public async Task CanRetrieveStatuses()
+ {
+ // Figured it was easier to grab the public status of a public repository for now than
+ // to go through the rigamarole of creating it all. But ideally, that's exactly what we'd do.
+
+ var githubClient = new GitHubClient(new ProductHeaderValue("OctokitTests"))
+ {
+ Credentials = Helper.Credentials
+ };
+ var statuses = await githubClient.Repository.CommitStatus.GetAll(
+ "rails",
+ "rails",
+ "94b857899506612956bb542e28e292308accb908");
+ Assert.Equal(2, statuses.Count);
+ Assert.Equal(CommitState.Failure, statuses[0].State);
+ Assert.Equal(CommitState.Pending, statuses[1].State);
+ }
+ }
+ }
+}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index 2f4ddd09..c0b63d67 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -56,6 +56,7 @@
+
diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs
new file mode 100644
index 00000000..05f2f9e3
--- /dev/null
+++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Threading.Tasks;
+using NSubstitute;
+using Octokit.Tests.Helpers;
+using Xunit;
+
+namespace Octokit.Tests.Clients
+{
+ public class CommitStatusClientTests
+ {
+ public class TheGetMethod
+ {
+ [Fact]
+ public void RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CommitStatusClient(connection);
+
+ client.GetAll("fake", "repo", "sha");
+
+ connection.Received()
+ .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/statuses/sha"), null);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var client = new CommitStatusClient(Substitute.For());
+
+ await AssertEx.Throws(async () =>
+ await client.GetAll("", "name", "sha"));
+ await AssertEx.Throws(async () =>
+ await client.GetAll("owner", "", "sha"));
+ await AssertEx.Throws(async () =>
+ await client.GetAll("owner", "name", ""));
+ await AssertEx.Throws(async () =>
+ await client.GetAll(null, "name", "sha"));
+ await AssertEx.Throws(async () =>
+ await client.GetAll("owner", null, "sha"));
+ await AssertEx.Throws(async () =>
+ await client.GetAll("owner", "name", null));
+ }
+ }
+
+ public class TheCreateMethodForUser
+ {
+ [Fact]
+ public void PostsToTheCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new CommitStatusClient(connection);
+
+ client.Create("owner", "repo", "sha", new NewCommitStatus { State = CommitState.Success });
+
+ connection.Received().Post(Arg.Is(u =>
+ u.ToString() == "repos/owner/repo/statuses/sha"),
+ Arg.Is(s => s.State == CommitState.Success));
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var client = new CommitStatusClient(Substitute.For());
+
+ await AssertEx.Throws(async () =>
+ await client.Create("", "name", "sha", new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create("owner", "", "sha", new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create("owner", "name", "", new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create(null, "name", "sha", new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create("owner", null, "sha", new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create("owner", "name", null, new NewCommitStatus()));
+ await AssertEx.Throws(async () =>
+ await client.Create("owner", "name", "sha", null));
+ }
+ }
+
+ public class TheConstructor
+ {
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ Assert.Throws(() => new CommitStatusClient(null));
+ }
+ }
+ }
+}
diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs
index feeeb080..bb517f26 100644
--- a/Octokit.Tests/Clients/RepositoriesClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs
@@ -27,33 +27,33 @@ namespace Octokit.Tests.Clients
[Fact]
public async Task EnsuresNonNullArguments()
{
- var repositoriesClient = new RepositoriesClient(Substitute.For());
+ var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await repositoriesClient.Create(null));
- await AssertEx.Throws(async () => await repositoriesClient.Create(new NewRepository { Name = null }));
+ await AssertEx.Throws(async () => await client.Create(null));
+ await AssertEx.Throws(async () => await client.Create(new NewRepository { Name = null }));
}
[Fact]
public void UsesTheUserReposUrl()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- repositoriesClient.Create(new NewRepository { Name = "aName" });
+ client.Create(new NewRepository { Name = "aName" });
- client.Received().Post(Arg.Is(u => u.ToString() == "user/repos"), Arg.Any());
+ connection.Received().Post(Arg.Is(u => u.ToString() == "user/repos"), Arg.Any());
}
[Fact]
public void TheNewRepositoryDescription()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
var newRepository = new NewRepository { Name = "aName" };
- repositoriesClient.Create(newRepository);
+ client.Create(newRepository);
- client.Received().Post(Arg.Any(), newRepository);
+ connection.Received().Post(Arg.Any(), newRepository);
}
}
@@ -62,22 +62,22 @@ namespace Octokit.Tests.Clients
[Fact]
public async Task EnsuresNonNullArguments()
{
- var repositoriesClient = new RepositoriesClient(Substitute.For());
+ var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await repositoriesClient.Create(null, new NewRepository { Name = "aName" }));
- await AssertEx.Throws(async () => await repositoriesClient.Create("aLogin", null));
- await AssertEx.Throws(async () => await repositoriesClient.Create("aLogin", new NewRepository { Name = null }));
+ await AssertEx.Throws(async () => await client.Create(null, new NewRepository { Name = "aName" }));
+ await AssertEx.Throws(async () => await client.Create("aLogin", null));
+ await AssertEx.Throws(async () => await client.Create("aLogin", new NewRepository { Name = null }));
}
[Fact]
public async Task UsesTheOrganizatinosReposUrl()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- await repositoriesClient.Create("theLogin", new NewRepository { Name = "aName" });
+ await client.Create("theLogin", new NewRepository { Name = "aName" });
- client.Received().Post(
+ connection.Received().Post(
Arg.Is(u => u.ToString() == "orgs/theLogin/repos"),
Args.NewRepository);
}
@@ -85,13 +85,13 @@ namespace Octokit.Tests.Clients
[Fact]
public async Task TheNewRepositoryDescription()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
var newRepository = new NewRepository { Name = "aName" };
- await repositoriesClient.Create("aLogin", newRepository);
+ await client.Create("aLogin", newRepository);
- client.Received().Post(Arg.Any(), newRepository);
+ connection.Received().Post(Arg.Any(), newRepository);
}
}
@@ -100,21 +100,21 @@ namespace Octokit.Tests.Clients
[Fact]
public async Task EnsuresNonNullArguments()
{
- var repositoriesClient = new RepositoriesClient(Substitute.For());
+ var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await repositoriesClient.Delete(null, "aRepoName"));
- await AssertEx.Throws(async () => await repositoriesClient.Delete("anOwner", null));
+ await AssertEx.Throws(async () => await client.Delete(null, "aRepoName"));
+ await AssertEx.Throws(async () => await client.Delete("anOwner", null));
}
[Fact]
public async Task RequestsCorrectUrl()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- await repositoriesClient.Delete("theOwner", "theRepoName");
+ await client.Delete("theOwner", "theRepoName");
- client.Received().Delete(Arg.Is(u => u.ToString() == "repos/theOwner/theRepoName"));
+ connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/theOwner/theRepoName"));
}
}
@@ -123,21 +123,21 @@ namespace Octokit.Tests.Clients
[Fact]
public void RequestsCorrectUrl()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- repositoriesClient.Get("fake", "repo");
+ client.Get("fake", "repo");
- client.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo"), null);
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo"), null);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
- var repositoriesClient = new RepositoriesClient(Substitute.For());
+ var client = new RepositoriesClient(Substitute.For());
- await AssertEx.Throws(async () => await repositoriesClient.Get(null, "name"));
- await AssertEx.Throws(async () => await repositoriesClient.Get("owner", null));
+ await AssertEx.Throws(async () => await client.Get(null, "name"));
+ await AssertEx.Throws(async () => await client.Get("owner", null));
}
}
@@ -146,12 +146,12 @@ namespace Octokit.Tests.Clients
[Fact]
public void RequestsTheCorrectUrlAndReturnsOrganizations()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- repositoriesClient.GetAllForCurrent();
+ client.GetAllForCurrent();
- client.Received()
+ connection.Received()
.GetAll(Arg.Is(u => u.ToString() == "user/repos"));
}
}
@@ -161,12 +161,12 @@ namespace Octokit.Tests.Clients
[Fact]
public void RequestsTheCorrectUrlAndReturnsOrganizations()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- repositoriesClient.GetAllForUser("username");
+ client.GetAllForUser("username");
- client.Received()
+ connection.Received()
.GetAll(Arg.Is(u => u.ToString() == "users/username/repos"));
}
@@ -184,12 +184,12 @@ namespace Octokit.Tests.Clients
[Fact]
public void RequestsTheCorrectUrlAndReturnsOrganizations()
{
- var client = Substitute.For();
- var repositoriesClient = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ var client = new RepositoriesClient(connection);
- repositoriesClient.GetAllForOrg("orgname");
+ client.GetAllForOrg("orgname");
- client.Received()
+ connection.Received()
.GetAll(Arg.Is(u => u.ToString() == "orgs/orgname/repos"));
}
@@ -216,21 +216,21 @@ namespace Octokit.Tests.Clients
Url = "https://github.example.com/readme.md",
HtmlUrl = "https://github.example.com/readme"
};
- var client = Substitute.For();
- client.Get(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
- client.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
- var reposEndpoint = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ connection.Get(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
+ connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
+ var reposEndpoint = new RepositoriesClient(connection);
var readme = await reposEndpoint.GetReadme("fake", "repo");
Assert.Equal("README.md", readme.Name);
- client.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"),
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"),
null);
- client.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"),
+ connection.DidNotReceive().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"),
null);
var htmlReadme = await readme.GetHtmlContent();
Assert.Equal("README", htmlReadme);
- client.Received().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), null);
+ connection.Received().GetHtml(Arg.Is(u => u.ToString() == "https://github.example.com/readme"), null);
}
}
@@ -239,13 +239,13 @@ namespace Octokit.Tests.Clients
[Fact]
public async Task ReturnsReadmeHtml()
{
- var client = Substitute.For();
- client.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
- var reposEndpoint = new RepositoriesClient(client);
+ var connection = Substitute.For();
+ connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("README"));
+ var reposEndpoint = new RepositoriesClient(connection);
var readme = await reposEndpoint.GetReadmeHtml("fake", "repo");
- client.Received().GetHtml(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), null);
+ connection.Received().GetHtml(Arg.Is(u => u.ToString() == "repos/fake/repo/readme"), null);
Assert.Equal("README", readme);
}
}
diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj
index 9301165c..ea824984 100644
--- a/Octokit.Tests/Octokit.Tests.csproj
+++ b/Octokit.Tests/Octokit.Tests.csproj
@@ -61,6 +61,7 @@
+
diff --git a/Octokit.Tests/OctokitRT.Tests.csproj b/Octokit.Tests/OctokitRT.Tests.csproj
index 6112365f..9b056a8c 100644
--- a/Octokit.Tests/OctokitRT.Tests.csproj
+++ b/Octokit.Tests/OctokitRT.Tests.csproj
@@ -52,6 +52,7 @@
+
diff --git a/Octokit/Clients/CommitStatusClient.cs b/Octokit/Clients/CommitStatusClient.cs
new file mode 100644
index 00000000..a9fb46cf
--- /dev/null
+++ b/Octokit/Clients/CommitStatusClient.cs
@@ -0,0 +1,62 @@
+#if NETFX_CORE
+using System.Collections.Generic;
+#endif
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ ///
+ /// A client for GitHub's Commit Status API.
+ ///
+ ///
+ /// See the Commit Status API documentation for more
+ /// details. Also check out the blog post
+ /// that announced this feature.
+ ///
+ public class CommitStatusClient : ApiClient, ICommitStatusClient
+ {
+ ///
+ /// Initializes a new Commit Status API client.
+ ///
+ /// An API connection.
+ public CommitStatusClient(IApiConnection apiConnection) : base(apiConnection)
+ {
+ }
+
+ ///
+ /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
+ /// a tag name.
+ ///
+ /// Only users with pull access can see this.
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ ///
+ public Task> GetAll(string owner, string name, string reference)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
+
+ return ApiConnection.GetAll(ApiUrls.CommitStatus(owner, name, reference), null);
+ }
+
+ ///
+ /// Creates a commit status for the specified ref.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ /// The commit status to create.
+ ///
+ public Task Create(string owner, string name, string reference, NewCommitStatus commitStatus)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
+ Ensure.ArgumentNotNull(commitStatus, "commitStatus");
+
+ return ApiConnection.Post(ApiUrls.CommitStatus(owner, name, reference), commitStatus);
+ }
+ }
+}
diff --git a/Octokit/Clients/ICommitStatusClient.cs b/Octokit/Clients/ICommitStatusClient.cs
new file mode 100644
index 00000000..41842253
--- /dev/null
+++ b/Octokit/Clients/ICommitStatusClient.cs
@@ -0,0 +1,31 @@
+#if NETFX_CORE
+using System.Collections.Generic;
+#endif
+using System.Threading.Tasks;
+
+namespace Octokit
+{
+ public interface ICommitStatusClient
+ {
+ ///
+ /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
+ /// a tag name.
+ ///
+ /// Only users with pull access can see this.
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ ///
+ Task> GetAll(string owner, string name, string reference);
+
+ ///
+ /// Creates a commit status for the specified ref.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ /// The commit status to create.
+ ///
+ Task Create(string owner, string name, string reference, NewCommitStatus commitStatus);
+ }
+}
diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs
index 0aaa7d8b..0e08da1c 100644
--- a/Octokit/Clients/IRepositoriesClient.cs
+++ b/Octokit/Clients/IRepositoriesClient.cs
@@ -125,5 +125,15 @@ namespace Octokit
/// Thrown when a general API error occurs.
///
Task GetReadmeHtml(string owner, string name);
+
+ ///
+ /// A client for GitHub's Commit Status API.
+ ///
+ ///
+ /// See the Commit Status API documentation for more
+ /// details. Also check out the blog post
+ /// that announced this feature.
+ ///
+ ICommitStatusClient CommitStatus { get; }
}
}
diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs
index 4af767db..d960e0d1 100644
--- a/Octokit/Clients/RepositoriesClient.cs
+++ b/Octokit/Clients/RepositoriesClient.cs
@@ -20,6 +20,7 @@ namespace Octokit
/// An API connection.
public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
{
+ CommitStatus = new CommitStatusClient(apiConnection);
}
///
@@ -183,5 +184,15 @@ namespace Octokit
var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name);
return await ApiConnection.GetHtml(endpoint, null);
}
+
+ ///
+ /// A client for GitHub's Commit Status API.
+ ///
+ ///
+ /// See the Commit Status API documentation for more
+ /// details. Also check out the blog post
+ /// that announced this feature.
+ ///
+ public ICommitStatusClient CommitStatus { get; private set; }
}
}
diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs
index 0901117c..ac2ee83f 100644
--- a/Octokit/Helpers/ApiUrls.cs
+++ b/Octokit/Helpers/ApiUrls.cs
@@ -234,5 +234,17 @@ namespace Octokit
{
return "repos/{0}/{1}/milestones".FormatUri(owner, name);
}
+
+ ///
+ /// Returns the that lists the commit statuses for the specified reference.
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The reference (SHA, branch name, or tag name) to list commits for.
+ ///
+ public static Uri CommitStatus(string owner, string name, string reference)
+ {
+ return "repos/{0}/{1}/statuses/{2}".FormatUri(owner, name, reference);
+ }
}
}
diff --git a/Octokit/Models/Request/NewCommitStatus.cs b/Octokit/Models/Request/NewCommitStatus.cs
new file mode 100644
index 00000000..711a282b
--- /dev/null
+++ b/Octokit/Models/Request/NewCommitStatus.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Octokit
+{
+ public class NewCommitStatus
+ {
+ ///
+ /// The state of the commit.
+ ///
+ public CommitState State { get; set; }
+
+ ///
+ /// URL associated with this status. GitHub.com displays this URL as a link to allow users to easily see the
+ /// ‘source’ of the Status. For example, if your Continuous Integration system is posting build status,
+ /// you would want to provide the deep link for the build output for this specific sha.
+ ///
+ public Uri TargetUrl { get; set; }
+
+ ///
+ /// Short description of the status.
+ ///
+ public string Description { get; set; }
+ }
+}
diff --git a/Octokit/Models/Response/CommitStatus.cs b/Octokit/Models/Response/CommitStatus.cs
new file mode 100644
index 00000000..9f72b6a0
--- /dev/null
+++ b/Octokit/Models/Response/CommitStatus.cs
@@ -0,0 +1,74 @@
+using System;
+
+namespace Octokit
+{
+ public class CommitStatus
+ {
+ ///
+ /// The date the commit status was created.
+ ///
+ public DateTimeOffset CreatedAt { get; set; }
+
+ ///
+ /// The date the commit status was updated.
+ ///
+ public DateTimeOffset UpdatedAt { get; set; }
+
+ ///
+ /// The state of the commit
+ ///
+ public CommitState State { get; set; }
+
+ ///
+ /// URL associated with this status. GitHub.com displays this URL as a link to allow users to easily see the
+ /// ‘source’ of the Status.
+ ///
+ public Uri TargetUrl { get; set; }
+
+ ///
+ /// Short description of the status.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// The unique identifier of the status.
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// The URL of the status.
+ ///
+ public Uri Url { get; set; }
+
+ ///
+ /// The user that created the status.
+ ///
+ public User Creator { get; set; }
+ }
+
+ ///
+ /// Represents the state of a commit.
+ ///
+ public enum CommitState
+ {
+ ///
+ /// The commit state is still being determined. A build server might set this when it starts a build.
+ ///
+ Pending,
+
+ ///
+ /// The build was successful for the commit.
+ ///
+ Success,
+
+ ///
+ /// There was some error with the build.
+ ///
+ Error,
+
+ ///
+ /// The build completed and reports a failure.
+ ///
+ Failure
+ }
+}
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index a7273532..3cee98a3 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -82,6 +82,8 @@
Properties\SolutionInfo.cs
+
+
@@ -91,8 +93,10 @@
+
+
diff --git a/Octokit/OctokitRT.csproj b/Octokit/OctokitRT.csproj
index 45e0b9f6..ae36d696 100644
--- a/Octokit/OctokitRT.csproj
+++ b/Octokit/OctokitRT.csproj
@@ -112,8 +112,10 @@
+
+
@@ -188,6 +190,7 @@
+
@@ -201,6 +204,7 @@
+