有没有一种方法可以使用 API 列出拉取请求文件(来自源分支)及其在 Azure Devops 中的位置?还有其他使用 C# 的方法吗?
Is there a way to list pull request files(from source branch) with it's location in Azure Devops using APIs? Is there any other way using C#?
我的要求是 read/extract 使用 API 或 C# 的 Azure DevOps 拉取请求中存在的每个文件的源代码。
我可以使用下面的示例 URL -
下载特定文件的代码
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path=/{CodePath}&version={branch name}&api-version=5.1
现在我需要文件列表及其在 Azure DevOps 分支中的存储位置
我已尝试从可用的 REST API 进行不同的 GET 调用。
例如:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/iterations/{iterationId}?api-version=5.1
或
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/attachments/{fileName}?api-version=5.1-preview.1
这些调用正在返回信息:
- 关于文件提交
- 关于描述中的附件
我必须满足的信息:
组织名称、存储库名称、分支名称、拉取请求 ID
Is there a way to list pull request files(from source branch) with it's location in Azure Devops using APIs? Is there any other way using C#?
恐怕没有这样的方法可以使用 APIs 列出拉取请求文件(来自源分支)及其在 Azure Devops 中的位置。
首先,当我们使用拉取请求API时,我们可以直接得到Organization name
和Pull request ID
。
然后我们可以使用 REST API Pull Requests - Get Pull Requests 来获取 repository name
和 sourceRefName
(Branch Name
):
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=5.1
其次,我们可以使用 REST API Pull Request Commits - Get Pull Request Commits 来获取 PR 中的提交:
然后,我们可以使用带有 REST API Commits - Get Changes 的提交 ID 到文件路径:
现在,我们得到了我们想要的所有信息。
希望这对您有所帮助。
我的要求是 read/extract 使用 API 或 C# 的 Azure DevOps 拉取请求中存在的每个文件的源代码。 我可以使用下面的示例 URL -
下载特定文件的代码GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path=/{CodePath}&version={branch name}&api-version=5.1
现在我需要文件列表及其在 Azure DevOps 分支中的存储位置
我已尝试从可用的 REST API 进行不同的 GET 调用。 例如:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/iterations/{iterationId}?api-version=5.1
或
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/attachments/{fileName}?api-version=5.1-preview.1
这些调用正在返回信息:
- 关于文件提交
- 关于描述中的附件
我必须满足的信息: 组织名称、存储库名称、分支名称、拉取请求 ID
Is there a way to list pull request files(from source branch) with it's location in Azure Devops using APIs? Is there any other way using C#?
恐怕没有这样的方法可以使用 APIs 列出拉取请求文件(来自源分支)及其在 Azure Devops 中的位置。
首先,当我们使用拉取请求API时,我们可以直接得到Organization name
和Pull request ID
。
然后我们可以使用 REST API Pull Requests - Get Pull Requests 来获取 repository name
和 sourceRefName
(Branch Name
):
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=5.1
其次,我们可以使用 REST API Pull Request Commits - Get Pull Request Commits 来获取 PR 中的提交:
然后,我们可以使用带有 REST API Commits - Get Changes 的提交 ID 到文件路径:
现在,我们得到了我们想要的所有信息。
希望这对您有所帮助。