Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS GIT REST API get related work items of commit

Tags:

I want to query GIT commits to get related works item IDs associated with particular commit. (https://www.visualstudio.com/en-us/docs/integrate/api/git/commits)

Request:

http://{server}/tfs/{collection}/{git repository}/_apis/git/repositories/{repository name}/commits?api-version=1.0

Unfortunately it returns truncated comments and because of that it is not always possible to see work item ID (#{Work Item ID}).

{
    "count": 100,
    "value": [{
            "commitId": "commit hash",
            "author": {
                "name": "some name",
                "email": "some email",
                "date": "2016-12-12T14:29:28Z"
            },
            "committer": {
                "name": "some name",
                "email": "some email",
                "date": "2016-12-12T14:29:28Z"
            },
            "comment": "Merge branch 'someBranch' of something.",
            "commentTruncated": true,
            "changeCounts": {
                "Add": 5,
                "Edit": 34
            },
            "url": "url",
            "remoteUrl": "remoteUrl"
        }]
}

In the response above the property "commentTruncated" is set to true. I have read the documentation, but did not find the solution to get either full comment or related work item separately.

like image 521
Viktors Telle Avatar asked Dec 13 '16 07:12

Viktors Telle


1 Answers

Ask the detail of each commit, e.g.

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4?api-version=1.0

See the Just the commit section in the docs.

like image 173
Giulio Vian Avatar answered Oct 10 '22 03:10

Giulio Vian