@@ -80,16 +80,20 @@ function Invoke-Create-Branch{
80
80
if ($repoRefUrlResponse.value.length -gt 0 )
81
81
{
82
82
Write-Host " Solution Repo - $repo has been Initialized"
83
- $sourceRefId = $null
84
83
$solutionBranchExists = $false
84
+ $sourceRefId = $null
85
85
# Check if 'Soure Branch' exists
86
86
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
+ }
87
91
if ($refBranch.name -eq " refs/heads/$solutionName " ){
88
92
$solutionBranchExists = $true
89
93
Write-Host " Solution Branch - $solutionName found."
90
94
}
91
95
}
92
-
96
+
93
97
# If Environment Names not provided, fall back to validation|test|prod.
94
98
if ([string ]::IsNullOrEmpty($environmentNames )){
95
99
Write-Host " EnvironmentNames not found in Settings. Falling back."
@@ -105,7 +109,7 @@ function Invoke-Create-Branch{
105
109
Get-Git - Commit- Changes " $organizationURL " " $buildProjectName " " $solutionProjectName " " $solutionRepositoryName " " $pipelineSourceDirectory " " $buildRepositoryName " " $buildSourceDirectory " " $solutionName " " $environmentName " " $agentPool " " $pipelineStageRunId "
106
110
}
107
111
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 " ){
109
113
# Create a new Branch
110
114
Write-Host " No commit changes. Creating new solution branch - $solutionName "
111
115
# Construct the request body for creating a new branch
0 commit comments