Pra*_*ian 4 c# azure-devops-rest-api
如果我有一个提交被合并到 20 个分支(可以有 20 个相应的 Pull 请求),是否有一个 API 可以使用原始叶提交 Id 作为参数来查找 20 个提交 Id 的列表?
GetPullRequests(string commitId)
Run Code Online (Sandbox Code Playgroud)
理想情况下会有一个 git rest API 方法来执行此操作,但我似乎找不到它。
谢谢!
我能够弄清楚。我们应该使用 PullRequestQuery 并传递提交列表作为输入。它将为我们输入的每个提交返回合并提交 ID 的字典。下面是获取一个提交 ID 的所有 PR 的代码。
public void GetAllPullRequestsForCommit(Guid repoId, string commitId)
{
var query = new GitPullRequestQuery();
var input = new GitPullRequestQueryInput() { Type = GitPullRequestQueryType.Commit, Items = new List<string>() { commitId } };
query.QueryInputs = new List<GitPullRequestQueryInput>() { input };
var response = _gitClient.GetPullRequestQueryAsync(query, repoId).Result;
var samplePullRequest = response.Results.SelectMany(x => x.Values).First().First().PullRequestId;
}
Run Code Online (Sandbox Code Playgroud)
更多信息请点击此处