【发布时间】:2019-04-24 13:45:36
【问题描述】:
在 TFVC 中,您可以将分支 A 中的变更集合并到分支 B。是否可以查看分支 A 中的哪些变更集(特别是哪些 id)被合并到分支 B 中?
【问题讨论】:
标签: tfs azure-devops tfvc
在 TFVC 中,您可以将分支 A 中的变更集合并到分支 B。是否可以查看分支 A 中的哪些变更集(特别是哪些 id)被合并到分支 B 中?
【问题讨论】:
标签: tfs azure-devops tfvc
您可以使用以下脚本:
$tfsUrl = "http://{Server}:{Port}/{Organization}/{Collection}"
$destinationBranchPath = "$/..."
$sourceBranchPath = "$/..."
# Change top with count of changesets you want to check
$body = 'repositoryId=&searchCriteria={"itemPath":"'+ $destinationBranchPath+'","itemVersion":"T","top":50}'
#Get top X changesets under destinationBranchPath
$changeSets = (Invoke-RestMethod -Method post "$tfsUrl/{Project}/_api/_versioncontrol/history?__v=5" -Body $body -UseDefaultCredentials).results
#Run over all changesets and check if sourceBranchPath is part of merage soruce path
foreach($changeSet in $changeSets)
{
$IsMerged = (Invoke-RestMethod -Method Get "$tfsUrl/_apis/tfvc/changesets/$($changeSet.changeList.changesetId)/changes" -UseDefaultCredentials).value.mergeSources.serverItem -like "*$sourceBranchPath*"
if($IsMerged)
{
#Print results
Write-Output $changeSet.changeList
}
}
【讨论】:
使用tf.exe 命令行工具,merges 命令可以提供两个分支之间的合并历史。
因此,在我的示例中,从本地计算机上的源代码管理根文件夹中,我可以在我选择的 shell tf vc merges a b /recursive 中运行以下命令,以获取来自 a 的哪些变更集包含在合并到的列表中b:
Changeset Merged in Changeset Author Date
--------- ------------------- -------------------------------- ----------
20096 20292 Joey Bloggs 30/04/2018
20102 20292 Joey Bloggs 30/04/2018
20103 20292 Joey Bloggs 30/04/2018
第一列包含来自分支 a 的变更集,第二列包含将其合并到分支 b 的变更集。
为了使这项工作正常进行,我必须将 tf.exe 的文件夹位置添加到我的 PATH 变量中。
【讨论】:
只是为不想使用命令的任何人添加另一种解决方案,但如果您想了解多个合并,这将更加耗时
在合并分支的 TFS 历史记录中,您可以右键单击变更集并选择 Track Changeset 选项,然后在下一个屏幕中选择原始分支 + 合并分支
【讨论】: