TFS 2010:如何使用标签在应用程序的两个版本之间生成更改日志(即工作项列表)?
我正在寻找一种在应用程序的两个版本之间自动生成变更日志(实际上是工作项列表)的方法。我的应用程序有两个版本:v1 和 v2,每个版本都由我在构建应用程序设置之前手动创建的 TFS 2010 中的标签(LABEL1 和 LABEL2)进行标识。 我有一个分支系统,这意味着我有一个主干,大多数错误都已修复,还有一个分支,其中主要使用来自主干的合并来应用补丁(但也有一些仅在分支上进行的修复,与主干无关) 。我的应用程序的两个版本(v1 和 v2)是来自分支的版本。
我希望 TFS 2010 能够返回这两个标签之间已修复的错误列表(即类型 = 已关闭和验证的错误的工作项列表)。
我尝试使用 TFS 2010 的 Web UI 或使用 Visual Studio 来实现此目的,但我没有找到任何方法。
然后我尝试使用以下命令行向 tf.exe 询问历史记录:
tf history /server:http://server_url/collection_name "$/project_path" /version:LLABEL1~LLABEL2 /recursive /noprompt /format:brief
其中 LABEL1 是与应用程序 v1 的源代码关联的标签,而 LABEL2 是与应用程序的源代码关联的标签应用程序的 v2。 它实际上以两种方式失败: - 命令行仅返回变更集列表,而不返回关联的已关闭工作项的列表 - 变更集列表仅包含我在分支本身上应用的变更集,而不包含我也应用和主干然后合并到分支的变更集。设置或不设置“/slotmode”参数不会改变任何内容。
在那里,我尝试编写一段 C# 代码来检索工作项列表(而不是变更集列表):
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://server_url/collection_name"));
VersionControlServer controlServer = tfs.GetService<VersionControlServer>();
VersionControlServer vcs = tfs.GetService<VersionControlServer>();
VersionSpec sFrom = VersionSpec.ParseSingleSpec("LLABEL1", null);
VersionSpec sTo = VersionSpec.ParseSingleSpec("LLABEL2", null);
var changesets = vcs.QueryHistory(
"$/project_path",
sTo,
0,
RecursionType.Full,
null,
sFrom,
sTo,
int.MaxValue,
true,
false); // Slotmode to false
Dictionary<int, WorkItem> dico = new Dictionary<int, WorkItem>();
foreach (Changeset set in changesets)
{
foreach (WorkItem zz in set.WorkItems)
{
if (!dico.ContainsKey(zz.Id))
{
dico.Add(zz.Id, zz);
}
}
}
foreach (KeyValuePair<int, WorkItem> pair in dico.OrderBy(z => z.Key))
{
Console.WriteLine(string.Format("ID: {0}, Title: {1}", pair.Key, pair.Value.Title));
}
这确实有效,我得到了两个标签之间的工作项列表,这实际上是我想要的。但仅考虑与在分支本身上提交的变更集关联的工作项:在主干上解决然后合并到分支的“Bug”类型的工作项不会出现。 Slotmode 不会改变任何东西。
然后我最终尝试用由变更集定义的 VersionSpec 替换由标签定义的 VersionSpec:
VersionSpec sFrom = VersionSpec.ParseSingleSpec("C5083", null);
VersionSpec sTo = VersionSpec.ParseSingleSpec("C5276", null);
我的代码终于可以工作了。
所以我的问题是:如何通过标签获得相同的结果,标签是我用来识别版本的 TFS 对象?如果不可能,我应该如何识别 TFS 2010 中的版本? 谢谢。
顺便说一句,我在 stackoverflow 上发现了一些问题,但没有一个给我带标签的答案。例如: 问题示例
I'm looking for a way to automatically produce a changelog (actually a list of workitems) between two releases of my application. I have two versions of my application, v1 and v2, each is identified by a label in TFS 2010 (LABEL1 and LABEL2) that I manually created before building the setups of my app.
I have a branching system, which means I have a trunk were most of bugs are fixed, and a branch where patches are applied mostly using merges from the trunk (but there are also some fixes on the branch only that do not concern the trunk). The two versions of my application (v1 and v2) are versions from the branch.
I would like TFS 2010 to be able to return the list of bugs that were fixed (ie. the list of work items with type = Bug that are closed and verified) between these two labels.
I tried to achieve this using the web UI of TFS 2010, or using Visual Studio, but I didn't find any way.
Then I tried to ask tf.exe for a history using the following command line:
tf history /server:http://server_url/collection_name "$/project_path" /version:LLABEL1~LLABEL2 /recursive /noprompt /format:brief
where LABEL1 is the label that has been associated with the source code of the v1 of the application, and LABEL2 the label that has been associated with the source code of the v2 of the application.
It actually fails in two ways:
- the command line only returns a list of changesets, not a list of associated closed work items
- the list of changesets only contains the changesets that I applied on the branch itself, not the changesets that I also applied and the trunk and then merged to the branch. Setting or not the "/slotmode" parameter doesn't change anything.
There I tried to write a piece of C# code to retrieve the list of workitems (not the list of changesets):
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://server_url/collection_name"));
VersionControlServer controlServer = tfs.GetService<VersionControlServer>();
VersionControlServer vcs = tfs.GetService<VersionControlServer>();
VersionSpec sFrom = VersionSpec.ParseSingleSpec("LLABEL1", null);
VersionSpec sTo = VersionSpec.ParseSingleSpec("LLABEL2", null);
var changesets = vcs.QueryHistory(
"$/project_path",
sTo,
0,
RecursionType.Full,
null,
sFrom,
sTo,
int.MaxValue,
true,
false); // Slotmode to false
Dictionary<int, WorkItem> dico = new Dictionary<int, WorkItem>();
foreach (Changeset set in changesets)
{
foreach (WorkItem zz in set.WorkItems)
{
if (!dico.ContainsKey(zz.Id))
{
dico.Add(zz.Id, zz);
}
}
}
foreach (KeyValuePair<int, WorkItem> pair in dico.OrderBy(z => z.Key))
{
Console.WriteLine(string.Format("ID: {0}, Title: {1}", pair.Key, pair.Value.Title));
}
This actually works, I get the list of workitems between my two labels which is actually what I wanted. But only workitems associated to changesets that were committed on the branch itself are taken into account: the workitems of type "Bug" that were solved on the trunk then merged to the branch don't appear. Slotmode doesn't change anything.
Then I finally tried to replace VersionSpecs that were defined by a label with VersionSpecs that are defined by changesets:
VersionSpec sFrom = VersionSpec.ParseSingleSpec("C5083", null);
VersionSpec sTo = VersionSpec.ParseSingleSpec("C5276", null);
And my code finally works.
So my question is: how could I get the same result with labels, which are the TFS objects I use to identify a version? If it's not possible, how should I identify a version in TFS 2010?
Thx.
Btw I found some questions on stackoverflow, but none of them gave me answers with labels. For instance:
Question example
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为 http://tfschangelog.codeplex.com/ 可能会在这里帮助你。
TFS ChangeLog 应用程序允许用户从 TFS 自动生成发行说明。用户必须提供有关其项目、分支和变更集范围的信息,然后 TFS ChangeLog 应用程序将从给定范围内的每个变更集以及此类变更集的所有关联工作项中提取信息。即,它将从开始变更集一直到结束变更集,并将提取有关每个变更集的数据以及 XML 文件中的关联工作项。
然后,用户可以使用自己的转换逻辑(包括过滤器、排序、样式、输出格式等)来生成发行说明报告。
我想在这里添加的另一件事与 TFS 中的标签有关。标签基本上是与变更集分配/关联的。目前,TFS ChangeLog 应用程序不支持标签来定义起点和终点,但它支持可用作解决方案的变更集。
希望这有用。
I think http://tfschangelog.codeplex.com/ can possibly help you here.
TFS ChangeLog applicatoin allows users to automatically generate release notes from TFS. Users will have to provide information on thier project, branch and changeset range and then TFS ChangeLog application will extract information from each changeset in a given range and all the associated workitems to such changesets. i.e. it will travel from starting changeset upto ending changeset and will extract data about each changeset along with associated workitems in an XML file.
Users can then use their own transformation logic including filter, sorting, styling, output formatting, etc. to generate Release Notes Report.
Another thing I would like to add here will be related to Labels in TFS. Labels are basically assigned / associated with changesets. Currently, TFS ChangeLog application does not support Labels to define starting and ending point but it does support changeset which can be used as a workaround solution.
Hope this is useful.
一般来说,在任何 SCM 中定义时间点的绝对方法显然是 checkin-id。
使用标签来抽象它,在 TFS 中并不是所讨论的最佳方式 此处 & 此处。更好的方法是使用构建,尤其是在现代 CI 环境中。
为了检索给定构建中包含的最大变更集,您必须执行以下操作:
上述操作的一个困难是检索您感兴趣的构建的 BuildUri。为了获取此信息,您可以执行以下操作:
然后检索对您很重要的 Uri。
这是如果您最终坚持使用标签,这也是一个很好的工具:除了
Uri
之外,每个build[]
还有一个LabelName
。In general, the absolute method of defining points in time in any SCM is clearly the checkin-id.
Using labels to abstract this, is in TFS not the optimum as discussed here & here. A better approach is to use builds instead, especially in a modern CI environment.
In order to retrieve the max changeset that was contained in a given build you 'd have to do something like this:
A difficulty with the above is to retrieve the BuildUri of the builds you are interested in. In order to get this information you could do something like this:
and then retrieve the Uri's that are important to you.
This is also a good vehicle if you eventually insist on using labels: Besides
Uri
, eachbuild[]
has also aLabelName
.我也遇到过和你一样的情况。我还希望包含合并变更集中的工作项。我只包含已完成的工作项。此外,如果同一工作项链接到多个变更集,则仅报告最后一个变更集。我在 CI 设置中使用它;并为每个构建创建一个变更日志。然后可以将
List
导出到 XML/HTML/TXT 文件。这是我的解决方案:I have been in the same situation as you. I also want Work Items from merged changesets included. I only include Work Items that are Done. Also if the same Work Item is linked to multiple changesets, only the last changeset is reported. I use this in a CI setup; and create a changelog for each build. The
List<ChangeInfo>
can then be exported to a XML/HTML/TXT-file. Here is my solution:这个问题让我更接近解决我遇到的类似问题。
对于标签版本,请使用
LabelVersionSpec
类型,而不是VersionSpec
。替换:
为:
This question got me closer to solving a similar problem I was having.
Use the type
LabelVersionSpec
instead ofVersionSpec
for label versions.Replace:
with: