public Package(Product product, CombinedCommitStatus commit, CommitStatus status) { Product = product; Commit = commit; Status = status; TargetUri = new Uri(status.TargetUrl); }
public async Task <string> SetStatus(string owner, string repository, string reference, string context, CommitState state, string description, string targetUrl) { if (String.IsNullOrEmpty(description)) { // Get current status with the same context to preserve description CombinedCommitStatus combined = await _client.Repository.CommitStatus.GetCombined(owner, repository, reference); var status = combined.Statuses.First(s => s.Context == context); description = status.Description; } NewCommitStatus newStatus = new NewCommitStatus() { Context = context, State = state, Description = description, TargetUrl = new Uri(targetUrl) }; try { var rslt = await _client.Repository.CommitStatus.Create(owner, repository, reference, newStatus); return(rslt.Id.ToString()); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get the date on which tests were run for the given pull request. /// </summary> /// <param name="pull"></param> public static DateTime GetTestDate(this PullRequest pull, string owner, string repo) { GitHubClient client = new GitHubClient(new ProductHeaderValue(owner)); client.Credentials = GetGitHubCredentials(); Task <IReadOnlyList <PullRequestCommit> > task = client.PullRequest.Commits(owner, repo, pull.Number); task.Wait(); IReadOnlyList <PullRequestCommit> commits = task.Result; if (commits.Any()) { Task <CombinedCommitStatus> statusTask = client.Repository.Status.GetCombined(owner, repo, commits.Last().Sha); statusTask.Wait(); CombinedCommitStatus combined = statusTask.Result; if (combined.Statuses.Any()) { return(combined.Statuses.Last().UpdatedAt.LocalDateTime); } } return(pull.UpdatedAt.DateTime); }