Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }