public override Task Process(string data) { var p = new PullRequestUrl(data); var c = GitClerk.CreateClient(); return(UpdateLabels(c, p, new[] { "ready for review", "ready to land", "comments addressed" }, new[] { "question" })); }
public override Task Process(string data) { var p = new PullRequestUrl(data); var c = GitClerk.CreateClient(); return(Task.WhenAll( UpdateLabels(c, p, new[] { "ready for review", "question" }, new[] { "ready to land" }), c.Issue.Comment.Create(p.Owner, p.Repo, p.Ticket, "LGTM :rainbow:"))); }
public override Task Process(string data) { var p = new PullRequestUrl(data); var c = GitClerk.CreateClient(); return(Task.WhenAll( UpdateLabels(c, p, new [] { "needs pollinating" }), c.Issue.Comment.Create(p.Owner, p.Repo, p.Ticket, ":hibiscus:"))); }
public override bool CanProcess(string data) { var p = new PullRequestUrl(data); if (p.Success) { Title = $"{Name} {p.Ticket}"; return(true); } return(false); }
protected async Task UpdateLabels(GitHubClient c, PullRequestUrl p, string[] removes = null, string[] adds = null) { var v = await c.Issue.Labels.GetAllForIssue(p.Owner, p.Repo, p.Ticket); var comparer = StringComparer.InvariantCultureIgnoreCase; var labelNames = v.Select(x => x.Name).ToList(); var actualRemoves = removes.EmptyIfNull().Intersect(labelNames, comparer); foreach (var l in actualRemoves) { await c.Issue.Labels.RemoveFromIssue(p.Owner, p.Repo, p.Ticket, l); } var newLabels = adds.EmptyIfNull().Except(labelNames, comparer).ToArray(); await c.Issue.Labels.AddToIssue(p.Owner, p.Repo, p.Ticket, newLabels); }