public PropertiesCollection GetPullRequestProperties() { VssConnection connection = Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); using (new ClientSampleHttpLoggerOutputSuppression()) { JsonPatchDocument patch = new JsonPatchDocument(); patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/sampleId", Value = 8 }); patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/startedDateTime", Value = DateTime.UtcNow }); gitClient.UpdatePullRequestPropertiesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult(); } Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId); PropertiesCollection properties = gitClient.GetPullRequestPropertiesAsync(repo.Id, pullRequest.PullRequestId).SyncResult(); Console.WriteLine($"Pull request {pullRequest.PullRequestId} has {properties.Count} properties"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); return(properties); }
public List <GitPullRequestStatus> GetPullRequestStatuses() { VssConnection connection = this.Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}"); List <GitPullRequestStatus> statuses = gitClient.GetPullRequestStatusesAsync(repo.Id, pullRequest.PullRequestId).Result; Console.WriteLine($"{statuses.Count} statuses found for pull request {pullRequest.PullRequestId}"); foreach (var status in statuses) { Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}"); } GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); return(statuses); }
public void UpdatePullRequestStatuses() { VssConnection connection = this.Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); GitPullRequestStatus status1 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); GitPullRequestStatus status2 = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}"); var patch = new JsonPatchDocument(); patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status1.Id}" }); patch.Add(new JsonPatchOperation() { Operation = VisualStudio.Services.WebApi.Patch.Operation.Remove, Path = $"/{status2.Id}" }); gitClient.UpdatePullRequestStatusesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult(); Console.WriteLine($"Statuses {status1.Id}, and {status2.Id} deleted from the pull request {pullRequest.PullRequestId}"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); }
public void DeletePullRequestStatus() { VssConnection connection = this.Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); GitPullRequestStatus status = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}"); gitClient.DeletePullRequestStatusAsync(repo.Id, pullRequest.PullRequestId, status.Id).SyncResult(); Console.WriteLine($"Status {status.Id} deleted from pull request {pullRequest.PullRequestId}"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); }
public GitPullRequestStatus GetPullRequestStatus() { VssConnection connection = this.Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); GitPullRequestStatus generatedStatus = GitSampleHelpers.CreatePullRequestStatus(this.Context, repo.Id, pullRequest.PullRequestId); Console.WriteLine($"project {project.Name}, repo {repo.Name}, pullRequestId {pullRequest.PullRequestId}"); GitPullRequestStatus status = gitClient.GetPullRequestStatusAsync(repo.Id, pullRequest.PullRequestId, generatedStatus.Id).Result; Console.WriteLine($"{status.Description}({status.Context.Genre}/{status.Context.Name}) with id {status.Id}"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); return(status); }
public GitPullRequestStatus CreatePullRequestStatusWithCustomProperties() { VssConnection connection = this.Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId); GitPullRequestStatus status = GitSampleHelpers.GenerateSampleStatus(includeProperties: true); GitPullRequestStatus createdStatus = gitClient.CreatePullRequestStatusAsync(status, repo.Id, pullRequest.PullRequestId).Result; Console.WriteLine($"{createdStatus.Description}({createdStatus.Context.Genre}/{createdStatus.Context.Name}) with id {createdStatus.Id} created"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); return(createdStatus); }
public PropertiesCollection AddPullRequestProperties() { VssConnection connection = Context.Connection; GitHttpClient gitClient = connection.GetClient <GitHttpClient>(); TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context); GitRepository repo = GitSampleHelpers.FindAnyRepository(this.Context, project.Id); GitPullRequest pullRequest = GitSampleHelpers.CreatePullRequest(this.Context, repo); Console.WriteLine("project {0}, repo {1}, pullRequestId {2}", project.Name, repo.Name, pullRequest.PullRequestId); JsonPatchDocument patch = new JsonPatchDocument(); patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/sampleId", Value = 8 }); patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/startedDateTime", Value = DateTime.UtcNow }); patch.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "", Value = new Dictionary <string, object>() { { "bytes", Encoding.UTF8.GetBytes("this is sample base64 encoded string") }, { "globalId", Guid.NewGuid() } } }); PropertiesCollection properties = gitClient.UpdatePullRequestPropertiesAsync(patch, repo.Id, pullRequest.PullRequestId).SyncResult(); Console.WriteLine($"Pull request {pullRequest.PullRequestId} has {properties.Count} properties"); GitSampleHelpers.AbandonPullRequest(this.Context, repo, pullRequest.PullRequestId); return(properties); }