使用 TFS REST API 获取 Git Commit 的最新关联工作项 [英] Get latest Associated Work Items for Git Commit using TFS REST API

查看:54
本文介绍了使用 TFS REST API 获取 Git Commit 的最新关联工作项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 使用 TFS REST API 的 GIT 提交.

我的请求网址如下所示:

My request URL looks like this:

http://tfs.server:8080/tfs/X/Y/_apis/git/repositories/GettingStarted.UI/commits/80186d385522150ee43ca85891fef565f37518df?api-version=3.0

在回复中,我发现了附加到评论的相关工作项:

In the response I have found the related work items appended to the Comment:

"comment": "合并 PR 4357:更正了客户端标头中 FEIN 的格式\n\n更正了客户端标头中 FEIN 的格式\n\n相关工作项:#539077"

"comment": "Merged PR 4357: Corrected format of FEIN in client header\n\nCorrected format of FEIN in client header\n\nRelated work items: #539077"

然而,当一个新的工作项与 Git Commit 相关联时,注释不会随之更新.有没有办法以结构化的方式获取当前关联的工作项?

However, when a new Work Item is associated to the Git Commit the comment is not updated with it. Is there a way to get the current associated Work Items in a structured way?

谢谢

推荐答案

你得到的是正确的情况.Git 提交可以通过多种方式链接到工作项.在 Pending Changes 窗口中,可以使用 UI 功能或通过以#ID"的形式向提交注释添加提及来添加工作项,其中 ID 是工作项 ID.

What you got is the correct situation. Git commits can be linked to work items for several ways. From the Pending Changes window, work items can be added using the UI features or by adding a mention to the commit comment in the form of "#ID" where ID is the work item ID.

根据您的评论,工作项 539077 在挂起更改期间通过 #ID 或通过 UI 链接到提交.但是,当新工作项也通过工作项 UI 或 Rest API 关联到同一个 Git 提交时.新链接的工作项不会在提交注释中更新.

According to your comment, work item 539077 is linked to the commit during the pending change either with #ID or through UI. However, when a new work item is also associated to the same Git Commit either through work item UI or Rest API. The new linked work item will not update in the commit comment.

除非您更新提交的注释,否则当您使用 TFS REST API 查询 GIT 提交时,注释的结果不会改变.

Unless you update the comment of the commit, the result of comment will not change when you query a GIT Commit using the TFS REST API.

对于与 Git Commit 关联的新工作项,您只能查询新工作项以获取提交 ID,无法查询提交以获取新工作项 ID.

For a new Work Item associated to the Git Commit, you could only be able to query the new work item toe get the commit ID, not able to query the commit to get new work item ID.

这篇关于使用 TFS REST API 获取 Git Commit 的最新关联工作项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆