Пример #1
0
        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" }));
        }
Пример #2
0
        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:")));
        }
Пример #3
0
        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:")));
        }
Пример #4
0
        public override bool CanProcess(string data)
        {
            var p = new PullRequestUrl(data);

            if (p.Success)
            {
                Title = $"{Name} {p.Ticket}";
                return(true);
            }
            return(false);
        }
Пример #5
0
        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);
        }