Adolfo Perez
Adolfo Perez

Reputation: 2874

Get latest Associated Work Items for Git Commit using TFS REST API

I'm trying to get the associated Work Items of a GIT Commit using the TFS REST API.

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": "Merged PR 4357: Corrected format of FEIN in client header\n\nCorrected format of FEIN in client header\n\nRelated work items: #539077"

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?

Thanks

Upvotes: 0

Views: 1239

Answers (1)

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51153

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.

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.

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.

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.

Upvotes: 0

Related Questions