Command/More/PredictMergeConflicts.ps1
Import-Module CmxModule -Force SetWindowTitle $MyInvocation.MyCommand.Name Write-Output "This script predicts merge conflicts . . . " Write-Output "Run GetPendingChanges . . . " $result = GetPendingChanges Write-Output "GetPendingChanges has finished" $exitCode = $result.ExitCode if($exitCode -ne 0) { Write-Output "ExitCode = $exitCode" Write-Output "$($result.StandardError)" Write-Output "$($result.StandardOutput)" } if($result.ExitedInTime -eq $false) { Write-Output "The command [GetPendingChanges] didn't exit it time!" exit 1 } $pendingChangeList = ConvertPendingChangesOutputToChangeList($result.StandardOutput) #$changes | Format-Table Write-Output "PendingChangeList Count: $($pendingChangeList.Count)" $workspace = $LocalWorkspace $changeset = "T" Write-Output "Changeset: $changeset" Write-Output "Workspace: $workspace" Write-Output "Run PreviewGetLatestByVersion . . . " $result = PreviewGetLatestByVersion -RootDir $workspace -ItemVersion $changeset Write-Output "PreviewGetLatestByVersion has finished" if($result.ExitedInTime -eq $false) { Write-Output "The command [PreviewGetLatestByVersion] didn't exit it time!" exit 1 } $serverChangeList = ConvertGetOutputToChangeList($result.StandardOutput) Write-Output "ChangeListCount: $($serverChangeList.Count)" Write-Output "ServerChangeList Count: $($serverChangeList.Count)" $result.StandardOutput | Out-File "c:\temp\ServerChangeList.txt" $collidingItems = New-Object System.Collections.Generic.List[PsCustomObject] foreach($changeItem1 in $pendingChangeList) { foreach($changeItem2 in $serverChangeList) { # if($changeItem1.LocalPath.Contains("Safety.Base.Test.csproj")) # { # if($changeItem2.LocalPath.ToLower().Contains("Safety.Base.Test.csproj")) # { # Write-Output "stop" # } # } if($changeItem1.LocalPath -eq $changeItem2.LocalPath) { $collidingItems.Add($changeItem1) } } } Write-Output "CollidingItems Count: $($collidingItems.Count)" $collidingItems # if($result.ExitCode -ne 0) # { # $previewResultString = "The preview detected issues, so the real command is not executed. " # $previewResultString += "Please fix these issues first, then try again." # Write-Output "PreviewResultString: $previewResultString" # Write-Output "" # Write-Output "ExitCode: $($result.ExitCode)" # Write-Output "" # Write-Output "Issues: " # Write-Output "$($result.StandardError)" # $serverChangeList = ConvertGetOutputToChangeList($result.StandardOutput) # Write-Output "ChangeListCount: $($serverChangeList.Count)" # } # else # { # Write-Output "There a no conflicts between your pendings changes and the current server" # } Read-Host "The script has finished. Press any key to exit" |