Ejemplo n.º 1
0
        public void RemoveIssueLabel(long repo, int issueNum, string label)
        {
            var isseuUpdate = new IssueUpdate();

            isseuUpdate.RemoveLabel(label);

            client.Issue.Update(repo, issueNum, isseuUpdate).Wait();
        }
Ejemplo n.º 2
0
        protected override async Task ProcessRecordAsync()
        {
            var repository = await GitHubClient.Repository.GetForOrg(Organization, Repository);

            var issue = await GitHubClient.Issue.Get(repository.Id, IssueNumber);

            var issueUpdate = new IssueUpdate()
            {
                Milestone = issue.Milestone?.Number
            };

            if (MileStoneTitle != null)
            {
                var milestone = await GitHubClient.Issue.Milestone.GetAllForRepository(repository.Id).ToObservable().SelectMany(list => list).FirstAsync(_ => _.Title == MileStoneTitle);

                issueUpdate.Milestone = milestone.Number;
            }

            if (State.HasValue)
            {
                issueUpdate.State = State;
            }

            if (Labels != null || RemoveLabels != null)
            {
                foreach (var label in issue.Labels.Select(label => label.Name.ToLower()).Except(RemoveLabels.Select(s => s.ToLower())))
                {
                    issueUpdate.AddLabel(label);
                }
                if (Labels != null)
                {
                    foreach (var label in Labels)
                    {
                        issueUpdate.AddLabel(label);
                    }
                }

                if (RemoveLabels != null)
                {
                    foreach (var label in RemoveLabels)
                    {
                        issueUpdate.RemoveLabel(label);
                    }
                }
            }

            await GitHubClient.Issue.Update(repository.Id, IssueNumber, issueUpdate)
            .ToObservable()
            .WriteObject(this)
            .HandleErrors(this);
        }