/// <summary>
        /// Creates an issue for the specified repository. Any user with pull access to a repository can create an
        /// issue.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/#create-an-issue</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="newIssue">A <see cref="NewIssue"/> instance describing the new issue to create</param>
        public IObservable <Issue> Create(string owner, string name, NewIssue newIssue)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(newIssue, "newIssue");

            return(_client.Create(owner, name, newIssue).ToObservable());
        }
Пример #2
0
        public async Task DeleteIssueComment()
        {
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));

            var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");

            await _issueCommentsClient.Delete(_context.RepositoryOwner, _context.RepositoryName, comment.Id);

            await Assert.ThrowsAsync <NotFoundException>(() => _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, comment.Id));
        }
Пример #3
0
        public async Task ReturnsIssueComment()
        {
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));

            var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");

            var loadedComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, comment.Id);

            Assert.Equal(comment.Id, loadedComment.Id);
            Assert.Equal(comment.Body, loadedComment.Body);
        }
        private async Task <IEnumerable <Issue> > CreateGitHubIssues(IEnumerable <NewIssue> gitHubIssuesToCreate)
        {
            var gitHubIssuesCreated = new List <Issue>();

            var issueCounter = 1.0d;


            //next step, add them to the github instance ...
            foreach (var gitHubIssue in gitHubIssuesToCreate)
            {
                if (Math.Abs(issueCounter % _settings.GitHubApiThrottleOnCreateInvocationCount) < 0.1)
                {
                    Logger.InfoFormat("Sleeping for {0} milliseconds to avoid GitHub anti-DoS policies on CREATE API calls...", _settings.GitHubApiThrottleOnCreatePauseDurationMilliseconds);
                    Thread.Sleep(_settings.GitHubApiThrottleOnCreatePauseDurationMilliseconds);
                }

                var issue = await _issuesClient.Create(_settings.GitHubRepositoryOwner, _settings.GitHubRepositoryName, gitHubIssue);

                Logger.InfoFormat("Added Issue #{0} to GitHub.", issue.Number);

                gitHubIssuesCreated.Add(issue);

                issueCounter++;
            }

            return(gitHubIssuesCreated);
        }
Пример #5
0
    public async Task CanListLabelsForAnIssue()
    {
        var newIssue = new NewIssue("A test issue")
        {
            Body = "A new unassigned issue"
        };
        var newLabel = new NewLabel("test label", "FFFFFF");

        var label = await _issuesLabelsClient.Create(_repositoryOwner, _repository.Name, newLabel);

        var issue = await _issuesClient.Create(_repositoryOwner, _repositoryName, newIssue);

        var issueLabelsInfo = await _issuesLabelsClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);

        Assert.Empty(issueLabelsInfo);

        var issueUpdate = new IssueUpdate();

        issueUpdate.Labels.Add(label.Name);
        var updated = await _issuesClient.Update(_repositoryOwner, _repository.Name, issue.Number, issueUpdate);

        Assert.NotNull(updated);
        issueLabelsInfo = await _issuesLabelsClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
    }
Пример #6
0
        public async Task UpdateIssueComment()
        {
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));

            var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");

            var commentId = comment.Id;

            var beforeComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, commentId);

            await _issueCommentsClient.Update(_context.RepositoryOwner, _context.RepositoryName, commentId, "test comment 2");

            var afterComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, commentId);

            Assert.Equal(beforeComment.Id, afterComment.Id);
            Assert.NotEqual(beforeComment.Body, afterComment.Body);
            Assert.Equal("test comment 2", afterComment.Body);
        }
        public async Task CanListReactions()
        {
            var newIssue = new NewIssue("a test issue")
            {
                Body = "A new unassigned issue"
            };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            Assert.NotNull(issue);

            var issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new NewReaction(ReactionType.Heart));

            var issueReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

            Assert.NotEmpty(issueReactions);

            Assert.Equal(issueReaction.Id, issueReactions[0].Id);
            Assert.Equal(issueReaction.Content, issueReactions[0].Content);
        }
        private Task <Issue> CreateNewIssueAsync(WorkItem workItem, IEnumerable <WorkItemFileAttachment> attachments)
        {
            var newIssue = new NewIssue(title: workItem.Summary)
            {
                Body = TextUtilities.GetFormattedWorkItemBody(workItem, attachments),
            };

            SetNewIssueLabels(newIssue.Labels, workItem);

            return(issues.Create(owner: repoOwner, name: repo, newIssue: newIssue));
        }
Пример #9
0
    public async Task CanListEventInfoForAnIssue()
    {
        var newIssue = new NewIssue("a test issue")
        {
            Body = "A new unassigned issue"
        };
        var issue = await _issuesClient.Create(_repositoryOwner, _repositoryName, newIssue);

        var issueEventInfo = await _issuesEventsClientClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);

        Assert.Empty(issueEventInfo);

        var closed = _issuesClient.Update(_repositoryOwner, _repository.Name, issue.Number, new IssueUpdate {
            State = ItemState.Closed
        })
                     .Result;

        Assert.NotNull(closed);
        issueEventInfo = await _issuesEventsClientClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);

        Assert.Equal(1, issueEventInfo.Count);
        Assert.Equal(EventInfoState.Closed, issueEventInfo[0].Event);
    }
Пример #10
0
        private async Task <Issue> FileIssueAsync(PortingInfo ruleToPort, string title)
        {
            Issue issue = null;

            NewIssue newIssue = CreateNewIssue(ruleToPort, title);

            if (_options.DryRun)
            {
                _log.Info(Resources.InfoDryRunIssueNotCreated);
                issue = MakeFakeIssue(newIssue);
            }
            else
            {
                issue = await _issuesClient.Create(_options.RepoOwner, _options.RepoName, newIssue);

                _log.InfoFormat(Resources.InfoIssueCreated, issue.Number);
            }

            return(issue);
        }
        public async Task CanCreateReaction()
        {
            var newIssue = new NewIssue("a test issue")
            {
                Body = "A new unassigned issue"
            };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            Assert.NotNull(issue);

            var issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new NewReaction(ReactionType.Heart));

            Assert.NotNull(issueReaction);

            Assert.IsType <Reaction>(issueReaction);

            Assert.Equal(ReactionType.Heart, issueReaction.Content);

            Assert.Equal(issue.User.Id, issueReaction.User.Id);
        }
        public async Task CanDeserializeRenameEvent()
        {
            var newIssue = new NewIssue("a test issue")
            {
                Body = "A new unassigned issue"
            };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var renamed = await _issuesClient.Update(_context.Repository.Id, issue.Number, new IssueUpdate { Title = "A test issue" });

            Assert.NotNull(renamed);
            Assert.Equal("A test issue", renamed.Title);

            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

            Assert.Equal(1, timelineEventInfos.Count);
            Assert.Equal("a test issue", timelineEventInfos[0].Rename.From);
            Assert.Equal("A test issue", timelineEventInfos[0].Rename.To);
        }
        public async Task CanRetrieveTimelineForIssue()
        {
            var newIssue = new NewIssue("a test issue")
            {
                Body = "A new unassigned issue"
            };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

            Assert.Empty(timelineEventInfos);

            var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate()
            {
                State = ItemState.Closed
            });

            Assert.NotNull(closed);

            timelineEventInfos = await _issueTimelineClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

            Assert.Equal(1, timelineEventInfos.Count);
            Assert.Equal(EventInfoState.Closed, timelineEventInfos[0].Event);
        }
Пример #14
0
        public void CreateIssue(ErrorReport errorReport)
        {
            var errorReportName = "Error Report " + errorReport.DateTime.ToString("yyyyMMddHHmmss");

            if (DoesIssueExist(errorReportName))
            {
                return;
            }

            var newIssue = new NewIssue(errorReportName);

            foreach (var label in _issueLabels)
            {
                newIssue.Labels.Add(label);
            }

            var body = JsonConvert.SerializeObject(errorReport);

            newIssue.Body = body;

            var task = _issuesClient.Create(_gitHubRepoInfo.Owner, _gitHubRepoInfo.Name, newIssue);

            task.Wait();
        }
Пример #15
0
    public async Task CanCreateRetrieveAndCloseIssue()
    {
        string owner = _repository.Owner.Login;

        var newIssue = new NewIssue("a test issue")
        {
            Body = "A new unassigned issue"
        };
        var issue = await _issuesClient.Create(owner, _repository.Name, newIssue);

        try
        {
            Assert.NotNull(issue);

            var retrieved = await _issuesClient.Get(owner, _repository.Name, issue.Number);

            var all = await _issuesClient.GetForRepository(owner, _repository.Name);

            Assert.NotNull(retrieved);
            Assert.True(all.Any(i => i.Number == retrieved.Number));
        }
        finally
        {
            var closed = _issuesClient.Update(owner, _repository.Name, issue.Number,
                                              new IssueUpdate {
                State = ItemState.Closed
            })
                         .Result;
            Assert.NotNull(closed);
        }
    }
    public async Task CanDeserializeIssue()
    {
        const string title       = "a test issue";
        const string description = "A new unassigned issue";
        var          newIssue    = new NewIssue(title)
        {
            Body = description
        };
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

        var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number);

        Assert.NotNull(retrieved);
        Assert.NotEqual(0, issue.Id);
        Assert.Equal(false, issue.Locked);
        Assert.Equal(title, retrieved.Title);
        Assert.Equal(description, retrieved.Body);
    }
Пример #17
0
 public void AddIssue(NewIssue issue, string repositorName, string ownerName)
 {
     issuesClient.Create(ownerName, repositorName, issue).GetAwaiter().GetResult();
 }