diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs
index bcca351d..d845d1f3 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs
@@ -23,5 +23,14 @@ namespace Octokit.Reactive
/// The name of the repository
///
IObservable GetAll(string owner, string name);
+
+ ///
+ /// Gets all commits for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Used to filter list of commits returned
+ ///
+ IObservable GetAll(string owner, string name, CommitRequest request);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs
index 55a7bd9e..1fc54f98 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs
@@ -37,11 +37,25 @@ namespace Octokit.Reactive
/// The name of the repository
///
public IObservable GetAll(string owner, string name)
+ {
+ return GetAll(owner, name, new CommitRequest());
+ }
+
+ ///
+ /// Gets all commits for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Used to filter list of commits returned
+ ///
+ public IObservable GetAll(string owner, string name, CommitRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
- return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name));
+ return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name),
+ request.ToParametersDictionary());
}
}
}
diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs
index 0349f83f..46fc5de2 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs
@@ -33,6 +33,46 @@ public class RepositoryCommitsClientTests : IDisposable
Assert.NotEmpty(list);
}
+ [IntegrationTest]
+ public async Task CanGetListOfCommitsBySha()
+ {
+ var request = new CommitRequest { Sha = "21599cd93657eeb7bde31989da61bd046c2ecd9e" };
+ var list = await _fixture.GetAll("octokit", "octokit.net", request);
+ Assert.NotEmpty(list);
+ }
+
+ [IntegrationTest]
+ public async Task CanGetListOfCommitsByPath()
+ {
+ var request = new CommitRequest { Path = "Octokit.Reactive/Clients" };
+ var list = await _fixture.GetAll("octokit", "octokit.net", request);
+ Assert.NotEmpty(list);
+ }
+
+ [IntegrationTest]
+ public async Task CanGetListOfCommitsByAuthor()
+ {
+ var request = new CommitRequest { Author = "haacked" };
+ var list = await _fixture.GetAll("octokit", "octokit.net", request);
+ Assert.NotEmpty(list);
+ }
+
+ [IntegrationTest]
+ public async Task CanGetListOfCommitsBySinceDate()
+ {
+ var request = new CommitRequest { Since = new DateTimeOffset(2014, 1, 1, 0, 0, 0, new TimeSpan(1, 0, 0)) };
+ var list = await _fixture.GetAll("octokit", "octokit.net", request);
+ Assert.NotEmpty(list);
+ }
+
+ [IntegrationTest]
+ public async Task CanGetListOfCommitsByUntilDate()
+ {
+ var request = new CommitRequest { Until = DateTimeOffset.Now };
+ var list = await _fixture.GetAll("octokit", "octokit.net", request);
+ Assert.NotEmpty(list);
+ }
+
[IntegrationTest]
public async Task CanCompareReferences()
{
diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs
index f535f613..2eee3e79 100644
--- a/Octokit.Tests/Clients/RepositoriesClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs
@@ -617,6 +617,8 @@ namespace Octokit.Tests.Clients
Assert.Throws(() => client.GetAll("owner", null));
Assert.Throws(() => client.GetAll("owner", ""));
+
+ Assert.Throws(() => client.GetAll("owner", "repo", null));
}
[Fact]
@@ -628,7 +630,8 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "name");
connection.Received()
- .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"));
+ .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"),
+ Arg.Any>());
}
}
}
diff --git a/Octokit/Clients/IRepositoryCommitsClient.cs b/Octokit/Clients/IRepositoryCommitsClient.cs
index 43e2a3d8..1364fc8b 100644
--- a/Octokit/Clients/IRepositoryCommitsClient.cs
+++ b/Octokit/Clients/IRepositoryCommitsClient.cs
@@ -24,5 +24,14 @@ namespace Octokit
/// The name of the repository
///
Task> GetAll(string owner, string name);
+
+ ///
+ /// Gets all commits for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Used to filter list of commits returned
+ ///
+ Task> GetAll(string owner, string name, CommitRequest request);
}
}
diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs
index a67fb6db..110b0518 100644
--- a/Octokit/Clients/RepositoryCommitsClient.cs
+++ b/Octokit/Clients/RepositoryCommitsClient.cs
@@ -37,11 +37,25 @@ namespace Octokit
/// The name of the repository
///
public Task> GetAll(string owner, string name)
+ {
+ return GetAll(owner, name, new CommitRequest());
+ }
+
+ ///
+ /// Gets all commits for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// Used to filter list of commits returned
+ ///
+ public Task> GetAll(string owner, string name, CommitRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
- return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name));
+ return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name),
+ request.ToParametersDictionary());
}
}
}
\ No newline at end of file
diff --git a/Octokit/Models/Request/CommitRequest.cs b/Octokit/Models/Request/CommitRequest.cs
new file mode 100644
index 00000000..eef46841
--- /dev/null
+++ b/Octokit/Models/Request/CommitRequest.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace Octokit
+{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ public class CommitRequest : RequestParameters
+ {
+ public CommitRequest()
+ {
+ }
+
+ ///
+ /// SHA or branch to start listing commits from.
+ ///
+ public string Sha { get; set; }
+
+ ///
+ /// Only commits containing this file path will be returned.
+ ///
+ public string Path { get; set; }
+
+ ///
+ /// GitHub login or email address by which to filter by commit author.
+ ///
+ public string Author { get; set; }
+
+ ///
+ /// Only commits after this date will be returned.
+ ///
+ public DateTimeOffset? Since { get; set; }
+
+ ///
+ /// Only commits before this date will be returned.
+ ///
+ public DateTimeOffset? Until { get; set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return String.Format(CultureInfo.InvariantCulture, "Sha: {0} ", Sha);
+ }
+ }
+ }
+}
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index e2a34b78..9b5a8ce6 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -325,6 +325,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 32316b15..ea1016e4 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -335,6 +335,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 57bed6ab..5107ae50 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -330,6 +330,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index a0e014be..59bc7503 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -322,6 +322,7 @@
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index a4fbbca9..1205fde3 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -326,6 +326,7 @@
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 47539cbb..af5b7802 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -72,6 +72,7 @@
+