Skip to content

Commit 6da230a

Browse files
Fix for solution branch creation (#335)
1 parent 7c69683 commit 6da230a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PowerShell/branch-pipeline-policy.ps1

+7-3
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,20 @@ function Invoke-Create-Branch{
8080
if($repoRefUrlResponse.value.length -gt 0)
8181
{
8282
Write-Host "Solution Repo - $repo has been Initialized"
83-
$sourceRefId = $null
8483
$solutionBranchExists = $false
84+
$sourceRefId = $null
8585
# Check if 'Soure Branch' exists
8686
foreach($refBranch in $repoRefUrlResponse.value){
87+
if($refBranch.name -eq "refs/heads/main"){
88+
$sourceRefId = $refBranch.objectId
89+
Write-Host "Source Branch - $sourceBranch found. objectId - $sourceRefId"
90+
}
8791
if($refBranch.name -eq "refs/heads/$solutionName"){
8892
$solutionBranchExists = $true
8993
Write-Host "Solution Branch - $solutionName found."
9094
}
9195
}
92-
96+
9397
# If Environment Names not provided, fall back to validation|test|prod.
9498
if([string]::IsNullOrEmpty($environmentNames)){
9599
Write-Host "EnvironmentNames not found in Settings. Falling back."
@@ -105,7 +109,7 @@ function Invoke-Create-Branch{
105109
Get-Git-Commit-Changes "$organizationURL" "$buildProjectName" "$solutionProjectName" "$solutionRepositoryName" "$pipelineSourceDirectory" "$buildRepositoryName" "$buildSourceDirectory" "$solutionName" "$environmentName" "$agentPool" "$pipelineStageRunId"
106110
}
107111

108-
if($solutionBranchExists -ne $true -and $createSolutionBranch -ne "false" -and $currentBranch -ne "$solutionName"){
112+
if($solutionBranchExists -ne $true -and $null -ne $sourceRefId -and $createSolutionBranch -ne "false" -and $currentBranch -ne "$solutionName"){
109113
# Create a new Branch
110114
Write-Host "No commit changes. Creating new solution branch - $solutionName"
111115
# Construct the request body for creating a new branch

0 commit comments

Comments
 (0)