using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit { /// /// A client for GitHub's Repository Commits API. /// /// /// See the Repository Commits API documentation for more information. /// public class RepositoryCommitsClient : IRepositoryCommitsClient { readonly IApiConnection _apiConnection; public RepositoryCommitsClient(IApiConnection apiConnection) { _apiConnection = apiConnection; } /// /// Compare two references in a repository /// /// The owner of the repository /// The name of the repository /// The reference to use as the base commit /// The reference to use as the head commit /// public Task Compare(string owner, string name, string @base, string head) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(@base, "base"); Ensure.ArgumentNotNullOrEmptyString(head, "head"); return _apiConnection.Get(ApiUrls.RepoCompare(owner, name, @base, head)); } /// /// Gets a single commit for a given repository /// /// The owner of the repository /// The name of the repository /// The reference for the commit (SHA) /// public Task Get(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _apiConnection.Get(ApiUrls.RepositoryCommit(owner, name, reference)); } /// /// Gets all commits for a given repository /// /// The owner of the repository /// 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), request.ToParametersDictionary()); } } }