是否存在将从所有更改集中提取config.json
文件的所有版本的tf command
?
我想看看它在发展过程中是如何变化的。
我使用的是Team Foundation Server 2012 (v11)。
您需要编写脚本…使用PowerShell或类似的工具
使用:
tf history /collection:{{https://server/collection}} {{$/project/path/file}} /format:brief /noprompt
获取文件的所有唯一更改集。提取表中每行的数字。正则表达式是一种简单的方法……每行的^d+
应该从每行的开头获取数字。
然后创建一个本地工作区来获取文件的副本,基本结构应该是这样的,但是您需要编写循环和变量插入的脚本:
md temp
cd temp
tf workspace /new /noprompt temporary-workspace /collection:{{https://server/collection}}
tv workfold /map $/project/path . /collection:{{https://server/collection}}
## foreach {{changesetnumber}} in {{history}}
tf get /version:c{{changesetnumber}} /overwrite /force /noprompt {{$/project/path/}}config.json
copy config.json ..config.json.{{changesetnumber}}
## end forach
tf workspace /delete temporary-workspace
应该为每个变更集创建一个编号的文件副本。
下面powershell脚本为我工作,但仍有点粗糙:
$tf = "C:Program Files (x86)Microsoft Visual Studio2019EnterpriseCommon7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerTF.exe"
$collectionUri = "https://dev.azure.com/jessehouwing"
$path = '$/agile2017'
$file = "xxxxxxx"
$history = & $tf history /collection:$collectionUri $path/$file /format:brief /noprompt
$changesets = $history | %{ Select-String -InputObject $_ -Pattern "^d+" }
$changesets = $changesets.Matches | %{ $_.value }
cd $env:temp
md temporary-workspace -force
md history -Force
cd temporary-workspace
& $tf workspace /new /noprompt temporary-workspace /collection:$collectionUri
& $tf workfold /map $path .
foreach ($changeset in $changesets)
{
& $tf get /version:c$changeset /overwrite /force /noprompt $path/$file
copy "$file" "..history$file.$changeset" -Force
}
& $tf workspace /delete temporary-workspace
cd ..
rd temporary-workspace -Recurse