public async Task <GitPullRequest> CompletePullRequestAsync(string repoUrl, int pullRequestId, string lastMergeSourceCommit) { var url = $"{repoUrl}/pullrequests/{pullRequestId}?api-version=5.1"; var request = new HttpRequestMessage(HttpMethod.Patch, url); request.Headers.Authorization = _authHeaderValue; var body = new GitPullRequest { Status = "completed", LastMergeSourceCommit = new GitCommitRef { CommitId = lastMergeSourceCommit }, CompletionOptions = new GitPullRequestCompletionOptions { BypassPolicy = true } }; var json = JsonSerializer.Serialize(body, body.GetType(), s_serializerOptions); request.Content = new StringContent(json, Encoding.UTF8, "application/json"); using var response = await _httpClient.SendAsync(request); response.EnsureSuccessStatusCode(); using var stream = await response.Content.ReadAsStreamAsync(); var data = await JsonSerializer.DeserializeAsync <GitPullRequest>(stream, s_serializerOptions); return(data); }
public PullRequestMonitorItem(IAzureDevOpsClient azDoClient, GitPullRequest pullRequest) { AzDoClient = azDoClient ?? throw new ArgumentNullException(nameof(azDoClient)); PullRequest = pullRequest ?? throw new ArgumentNullException(nameof(pullRequest)); }