Which branches have changes which need to be merged?
I am currently on a project with a large development team. Some of the developers are learning how to code X++, so one feature can turn into six check ins. Therefore, I needed a way to review all non-promoted changes before I rolled out the next release. I can check using Visual Studio with four clicks, but I have to check twenty or so branches. My case may be an extreme example because every developer has their own branch; however, the resulting script is very useful. Anyways, there are ways to check what can be promoted using the TF tool:Copy to Clipboard1
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe" merge /candidate /recursive $/proj/dev1 $/proj/trunk
For some time, I had a text document with twenty of these commands that I would run…the format of the data returned was very much from the DOS ages. This did not make my life any easier. So I enhanced my solution, I took the output of that command and parsed it with PowerShell and combined result sets to have a single view and export to CSV for a single view of all possible changesets available for promotion. It also includes a URL to the changeset in Azure DevOps.
Get-DevOpsCandidates PowerShell Cmdlet
Download the PowerShell command from GitHub then import the function:Copy to Clipboard1
. '.\Get-DevOpsCandidates.ps1'
List the changesets which can be merged from dev branch 1 to trunk:Copy to Clipboard1
Get-DevOpsCandidates "$/DevOpsProject/dev1" "$/DevOpsProject/Trunk"
Checking Multiple Branches at the Same Time
Check all dev branches for merge candidates and save the output to CSV for filtering/sorting.Copy to Clipboard1
[string[]]$devBranches = "$/DevOpsProject/dev1", "$/DevOpsProject/dev2", "$/DevOpsProject/dev3", "$/DevOpsProject/dev4", "$/DevOpsProject/dev5", "$/DevOpsProject/dev6", "$/DevOpsProject/dev7", "$/DevOpsProject/dev8", "$/DevOpsProject/dev9", "$/DevOpsProject/dev10", "$/DevOpsProject/dev11", "$/DevOpsProject/dev12"
[string]$promoteToBranch = "$/DevOpsProject/Trunk"
Get-DevOpsCandidates $devBranches $promoteToBranch | Export-Csv -NoTypeInformation -Path "$env:USERPROFILE\Desktop\Promotion Candidates for Trunk.csv"
Output of command in CSV form