您不能仅通过WorkItemHttpClient
来获得提交注释,可以与GitHttpClient
一起获得。首先,使用WorkItemHttpClient
获取工作项链接,然后使用GitHttpClient
获取提交ID和评论。
一个工作示例:
VssClientCredentials cred = new VssClientCredentials();
VssConnection tfs = new VssConnection(new Uri("http://tfs-server:8080/tfs/collection"),cred);
var workItemClient = tfs.GetClient<WorkItemTrackingHttpClient>();
var gitClient = tfs.GetClient<GitHttpClient>();
int workItemId = 1213;
var workItem = workItemClient.GetWorkItemAsync("Project-Name",workItemId,expand: WorkItemExpand.Relations).Result;
// We need to retrieve the commit id from the links,debug the following line to understand what I did
var commitId = wit.Relations.Where(r => r.Url.Contains("Git")).FirstOrDefault().Url.Split('%')[2].Remove(0,2);
var commit = gitClient.GetCommitAsync("Project-Name",commitId,"Repo-Name").Result;
string comment = commit.comment;
顺便说一句,您不能使用Fixes #123
语法,因为TFS 2017不支持该语法。
本文链接:https://www.f2er.com/3103875.html