如何从TFS命令行命令获取合并候选项的变更集注释?

时间:2012-08-15 18:36:11

标签: tfs tfs2010

我想在两个分支之间生成一个合并候选列表,其中包含我可以在电子邮件中复制粘贴的格式的变更集注释。

我知道我可以执行此命令:

tf merge /candidate $/Branch1 $/Branch2

返回此内容:

Changeset Author                           Date
--------- -------------------------------- ----------
   22282  developer1                       08/09/2012
   22354  developer2                       08/14/2012
   22361  developer2                       08/14/2012
   22365  developer2                       08/14/2012
   22381  developer3                       08/15/2012

但是,我也想收到评论。在执行"选择的变更集"时,合并向导会执行类似的操作。合并。这是一个例子:

enter image description here

我想我可能能够以某种方式将tf merge /candidate与此命令结合使用:

tf changeset /noprompt 12345

其中输出的内容如下:

Changeset: 12345
User: developer1
Date: Thursday, August 09, 2012 5:20:01 PM

Comment:
  Completed various things

Items:
  merge, edit $/Branch1/BreakFreely.asmx.vb
  merge, edit $/Branch1/FreelyBroken.vb

Work Items:
  ID    Type                State Assigned To  Title
  ----- ------------------- ----- ------------ -----------------------------------------------------------------------------
  21406 Sprint Backlog Task Done  JoDeveloper1 Fix various things

Check-in Notes:
  Code Reviewer:
    Complete Lyblind

总之,我希望的结果是这样的:

Changeset Author                           Date       Comment
--------- -------------------------------- ---------- --------------------------
   22282  developer1                       08/09/2012 Fixed random stuff
   22354  developer2                       08/14/2012 Fixed specific stuff

您怎么看?

1 个答案:

答案 0 :(得分:3)

如果您愿意使用TFS-SDK并编写自己的控制台应用程序,这应该非常简单。
以下内容可以作为一个快速启动:

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace MergeCandidates
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSURI"));

            var versionControl = teamProjectCollection.GetService<VersionControlServer>();
            var mergeCandidates =
                versionControl.GetMergeCandidates(@"$/FromPath",
                                                  @"$/ToPath", RecursionType.Full);
            foreach (var mergeCandidate in mergeCandidates)
            {  
                Console.WriteLine(string.Format("{0} {1} {2} {3}",
                                                mergeCandidate.Changeset.ChangesetId,
                                                mergeCandidate.Changeset.Owner, 
                                                mergeCandidate.Changeset.CreationDate,
                                                mergeCandidate.Changeset.Comment));
            }
        }
    }
}