10

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

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

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

不过,我也想得到评论。合并向导在执行“选定的变更集”合并时会执行类似的操作。这是一个例子:

在此处输入图像描述

我在想我可能能够以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

你怎么看?

4

1 回答 1

3

In case you 're willing to utilize the TFS-SDK and write your own console app, this should be quite straightforward.
The following could serve as a jump-start:

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));
            }
        }
    }
}
于 2012-08-16T10:29:51.777 回答