예제 #1
0
        /// <summary>
        /// Gets commits from specified branch in specified repository.
        /// </summary>
        /// <param name="username">The repository owner name.</param>
        /// <param name="repositoryName">The repository name.</param>
        /// <param name="branchName">The branch name.</param>
        /// <returns>ClientResponse instance with collections of commits.</returns>
        public async Task <ClientResponse <IEnumerable <Commit> > > GetBranchCommits(string username, string repositoryName, string branchName)
        {
            if (username == string.Empty || repositoryName == string.Empty || branchName == string.Empty)
            {
                var clientResponse = new ClientResponse <IEnumerable <Commit> >
                {
                    Message = MessagesHelper.EmptyDataMessage,
                    Status  = OperationStatus.EmptyData
                };
                return(clientResponse);
            }

            var url =
                $"/{UrlConstants.RepositoriesUrlPart}/{username}/{repositoryName}/{UrlConstants.CommitsUrlPart}?sha={branchName}";
            HttpResponseMessage httpResponse = await this.requestSender.SendGetRequestToGitHubApiAsync(url);

            return(await this.requestSender.ProcessHttpResponse <IEnumerable <Commit> >(
                       httpResponse,
                       MessagesHelper.GenerateRepoUserBranchNotFoundMessage(username, repositoryName, branchName)));
        }