/// <summary> /// Creates a new Commit Comment for a specified Commit. /// </summary> /// <param name="repositoryId">The ID of the repository</param> /// <param name="sha">The sha reference of commit</param> /// <param name="newCommitComment">The new comment to add to the commit</param> /// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks> public Task <CommitComment> Create(int repositoryId, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); Ensure.ArgumentNotNull(newCommitComment, "newCommitComment"); return(ApiConnection.Post <CommitComment>(ApiUrls.CommitComments(repositoryId, sha), newCommitComment)); }
/// <summary> /// Creates a new Commit Comment for a specified Commit. /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="sha">The sha reference of commit</param> /// <param name="newCommitComment">The new comment to add to the commit</param> /// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks> public Task <CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); Ensure.ArgumentNotNull(newCommitComment, "newCommitComment"); return(ApiConnection.Post <CommitComment>(ApiUrls.CommitComments(owner, name, sha), newCommitComment)); }
/// <summary> /// Creates a new Commit Comment for a specified Commit. /// </summary> /// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="sha">The sha reference of commit</param> /// <param name="newCommitComment">The new comment to add to the commit</param> /// <returns></returns> public Task<CommitComment> Create(string owner, string name, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); Ensure.ArgumentNotNull(newCommitComment, "newCommitComment"); return ApiConnection.Post<CommitComment>(ApiUrls.CommitComments(owner, name, sha), newCommitComment); }
public ChangesetDiffViewModel(ISessionService sessionService, IActionMenuFactory actionMenuFactory, IAlertDialogFactory alertDialogFactory) { var comments = new ReactiveList<CommitComment>(); Comments = comments.CreateDerivedCollection( x => new FileDiffCommentViewModel(x.User.Login, x.User.AvatarUrl, x.Body, x.Position ?? 0)); var gotoCreateCommentCommand = ReactiveCommand.Create().WithSubscription(_ => { var vm = new ComposerViewModel(async s => { var cmd = new NewCommitComment(s) { Path = Filename, Position = SelectedPatchLine.Item1 }; var comment = await sessionService.GitHubClient.Repository.RepositoryComments.Create(Username, Repository, Branch, cmd); _commentCreatedObservable.OnNext(comment); comments.Add(comment); }, alertDialogFactory); NavigateTo(vm); }); GoToCommentCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.SelectedPatchLine).Select(x => x != null), sender => { var sheet = actionMenuFactory.Create(); sheet.AddButton(string.Format("Add Comment on Line {0}", SelectedPatchLine.Item2), gotoCreateCommentCommand); return sheet.Show(sender); }); _patch = this.WhenAnyValue(x => x.CommitFile) .IsNotNull().Select(x => x.Patch).ToProperty(this, x => x.Patch); this.WhenAnyValue(x => x.Filename).Subscribe(x => { if (string.IsNullOrEmpty(x)) Title = "Diff"; else { _actualFilename = Path.GetFileName(Filename) ?? Filename.Substring(Filename.LastIndexOf('/') + 1); Title = _actualFilename; } }); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { sessionService.GitHubClient.Repository.RepositoryComments.GetAllForCommit(Username, Repository, Branch) .ToBackground(x => comments.Reset(x.Where(y => string.Equals(y.Path, Filename)))); var commits = await sessionService.GitHubClient.Repository.Commits.Get(Username, Repository, Branch); CommitFile = commits.Files.FirstOrDefault(x => string.Equals(x.Filename, Filename, StringComparison.Ordinal)); }); }
public async Task CanCreateReaction() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, comment); Assert.NotNull(result); var newReaction = new NewReaction(ReactionType.Confused); var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(ReactionType.Confused, reaction.Content); Assert.Equal(result.User.Id, reaction.User.Id); }
public async Task CanListReactionsWithRepositoryId() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, comment); Assert.NotNull(result); var newReaction = new NewReaction(ReactionType.Confused); var reaction = await _github.Reaction.CommitComment.Create(_context.Repository.Id, result.Id, newReaction); var reactions = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id); Assert.NotEmpty(reactions); Assert.Equal(reaction.Id, reactions[0].Id); Assert.Equal(reaction.Content, reactions[0].Content); }
/// <summary> /// Creates a new Commit Comment for a specified Commit. /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="sha">The sha reference of commit</param> /// <param name="newCommitComment">The new comment to add to the commit</param> /// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks> public Task<CommitComment> Create(long repositoryId, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); Ensure.ArgumentNotNull(newCommitComment, "newCommitComment"); return ApiConnection.Post<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), newCommitComment); }
public async Task CanDeleteComment() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, comment); Assert.NotNull(result); var retrievedBefore = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.NotNull(retrievedBefore); await _github.Repository.Comment.Delete(_context.RepositoryOwner, _context.RepositoryName, result.Id); var notFound = false; try { await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); } catch (NotFoundException) { notFound = true; } Assert.True(notFound); }
public async Task CanUpdateComment() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, comment); Assert.NotNull(result); var retrievedBefore = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.NotNull(retrievedBefore); await _github.Repository.Comment.Update(_context.RepositoryOwner, _context.RepositoryName, result.Id, "new comment"); var retrievedAfter = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.Equal("new comment", retrievedAfter.Body); }
public async Task CanCreateComment() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, comment); Assert.NotNull(result); var retrieved = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.NotNull(retrieved); }
public async Task CanGetReactionPayload() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.Repository.Id, commit.Sha, comment); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(result.User.Id, reaction.User.Id); } var retrieved = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.True(retrieved.Id > 0); Assert.Equal(6, retrieved.Reactions.TotalCount); Assert.Equal(1, retrieved.Reactions.Plus1); Assert.Equal(1, retrieved.Reactions.Hooray); Assert.Equal(1, retrieved.Reactions.Heart); Assert.Equal(1, retrieved.Reactions.Laugh); Assert.Equal(1, retrieved.Reactions.Confused); Assert.Equal(1, retrieved.Reactions.Minus1); }
public async Task PostsToCorrectUrlWithRepositoryId() { var newComment = new NewCommitComment("body"); var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await client.Create(1, "sha", newComment); connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any<object>()); }
public void PostsToCorrectUrl() { NewCommitComment newComment = new NewCommitComment("body"); var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); client.Create("fake", "repo", "sha", newComment); connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<object>()); }