/// <summary> /// Votes for the pullrequest. /// </summary> /// <param name="vote">The vote for the pull request.</param> public void Vote(TfsPullRequestVote vote) { if (!this.ValidatePullRequest()) { return; } Identity authorizedIdenity; using (var gitClient = this.CreateGitClient(out authorizedIdenity)) { var request = gitClient.CreatePullRequestReviewerAsync( new IdentityRefWithVote() { Vote = (short)vote }, this.pullRequest.Repository.Id, this.pullRequest.PullRequestId, authorizedIdenity.Id.ToString(), CancellationToken.None); var createdReviewer = request.Result; var createdVote = (TfsPullRequestVote)createdReviewer.Vote; this.Log.Verbose("Voted for pull request with '{0}'.", createdVote.ToString()); } }
public static void TfsVotePullRequest( this ICakeContext context, TfsPullRequestSettings settings, TfsPullRequestVote vote) { context.NotNull(nameof(context)); settings.NotNull(nameof(settings)); new TfsPullRequest(context.Log, settings, new GitClientFactory()).Vote(vote); }
public static void TfsVotePullRequest( this ICakeContext context, TfsPullRequestSettings settings, TfsPullRequestVote vote) { context.NotNull(nameof(context)); settings.NotNull(nameof(settings)); var pullRequest = new TfsPullRequestSystem(context.Log, settings); pullRequest.Vote(vote); }
/// <summary> /// Votes for the pullrequest. /// </summary> /// <param name="vote">The vote for the pull request.</param> /// <exception cref="TfsPullRequestNotFoundException">If pull request could not be found and /// <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception> public void Vote(TfsPullRequestVote vote) { if (!this.ValidatePullRequest()) { return; } using (var gitClient = this.gitClientFactory.CreateGitClient(this.CollectionUrl, this.credentials, out var authorizedIdenity)) { var request = gitClient.CreatePullRequestReviewerAsync( new IdentityRefWithVote() { Vote = (short)vote }, this.pullRequest.Repository.Id, this.pullRequest.PullRequestId, authorizedIdenity.Id.ToString(), CancellationToken.None); try { var createdReviewer = request.Result; if (createdReviewer == null) { throw new TfsPullRequestNotFoundException( this.pullRequest.Repository.Id, this.pullRequest.PullRequestId); } var createdVote = (TfsPullRequestVote)createdReviewer.Vote; this.log.Verbose("Voted for pull request with '{0}'.", createdVote.ToString()); } catch (Exception ex) { this.log.Error("Error voting on pull request: " + ex.InnerException?.Message); throw; } } }