从Merge获取Changeset Id(s)

问题描述 投票:1回答:2

在TFVC中,您可以将分支A中的变更集合并到分支B.是否可以查看分支A中哪些变更集(特别是哪些ID)合并到分支B中?

tfs azure-devops tfvc
2个回答
1
投票

您可以使用以下脚本:

$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
   }
}

0
投票

使用tf.exe命令行工具,merges命令可以提供两个分支之间的合并历史记录。

因此,在我的示例中,从我本地计算机上的源代码控制根文件夹中,我可以在我选择的tf vc merges a b /recursive的shell中运行以下命令,以获取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变量。

© www.soinside.com 2019 - 2024. All rights reserved.