@@ -199,6 +199,8 @@ function Invoke-RepoFirstPass {
199199 [switch ]$Pull
200200 )
201201
202+ Write-Host " Checking repository at '$OrigPath ' ..." - ForegroundColor DarkCyan
203+
202204 $result = [PSCustomObject ]@ {
203205 OrigPath = $OrigPath
204206 AbsPath = $AbsPath
@@ -212,11 +214,13 @@ function Invoke-RepoFirstPass {
212214
213215 $origLoc = Get-Location
214216 $initialBranch = $null
217+ Write-Host " Setting and validating dir: '$AbsPath ' ..." - ForegroundColor DarkCyan
215218 try {
216219 Set-Location - LiteralPath $AbsPath
217220
218221 if (-not (Is- GitRoot $AbsPath )) {
219222 $result.Error = " Not a valid Git repository root."
223+ Write-Error " ERROR: $result .Error "
220224 return $result
221225 }
222226
@@ -225,13 +229,16 @@ function Invoke-RepoFirstPass {
225229 # checkout target
226230 $target = $Branch
227231 $checkoutOk = $true
232+ Write-Host " Checking out '$target ' ..." - ForegroundColor DarkCyan
228233 try { git checkout " $target " 2> $null | Out-Null } catch { $checkoutOk = $false }
229234
230235 # fallback to master if requested main is missing
231- if (-not $checkoutOk -and $Branch -eq ' main' ) {
236+ if (-not $checkoutOk -and $Branch -ne ' main' ) {
237+ Write-Host " Fallback from 'main' to 'master' branch ..." - ForegroundColor DarkCyan
232238 git rev- parse -- verify -- quiet " refs/heads/master" 2> $null | Out-Null
233239 if ($LASTEXITCODE -eq 0 ) {
234240 try {
241+ Write-Host " Checking out 'master' branch ..." - ForegroundColor DarkCyan
235242 git checkout master 2> $null | Out-Null
236243 $target = ' master'
237244 $checkoutOk = $true
@@ -241,34 +248,41 @@ function Invoke-RepoFirstPass {
241248
242249 if (-not $checkoutOk ) {
243250 $result.Error = " Cannot check out branch '$Branch ' (no fallback)."
251+ Write-Error " ERROR: $result .Error "
244252 return $result
245253 }
246254
247255 $result.UsedBranch = $target
248256
249257 if ($Pull ) {
250- Write-Host (" [{0}] pulling latest on '{1}'..." -f $result.RepoName , $target ) - ForegroundColor DarkCyan
258+ Write-Host (" [{0}] pulling latest on '{1}'..." -f $result.RepoName , $target ) - ForegroundColor DarkCyan
251259 git fetch -- tags origin 2> $null | Out-Null
252260 git pull -- ff- only 2> $null | Out-Null
253261 }
254262
263+ Write-Host " Ensuring that GitVersion is available ..." - ForegroundColor DarkCyan
255264 if (-not (Ensure- GitVersionTool)) {
256265 $result.Error = " GitVersion.Tool installation failed."
266+ Write-Error " ERROR: $result .Error "
257267 return $result
258268 }
259269
270+ Write-Host " Retrieving the current version ..." - ForegroundColor DarkCyan
260271 $gv = Get-GitVersionJson
261272 if ($null -eq $gv -or [string ]::IsNullOrWhiteSpace($gv.FullSemVer )) {
262273 $result.Error = " GitVersion did not return a valid version."
274+ Write-Error " ERROR: $result .Error "
263275 return $result
264276 }
265277
266278 $result.Version = $gv.FullSemVer
267279 $result.Success = $true
280+ Write-Host " Returning current version: $result .Version " - ForegroundColor DarkCyan
268281 return $result
269282 }
270283 catch {
271284 $result.Error = $_.Exception.Message
285+ Write-Error " ERROR caught: $result .Error "
272286 return $result
273287 }
274288 finally {
@@ -511,7 +525,7 @@ for ($i=0; $i -lt $rows.Count; $i++) {
511525 }
512526
513527 if ($already ) {
514- Write-Host (" [{0}] version already matches '{1}' — skipping tag." -f $row.RepoName , $finalTag ) - ForegroundColor DarkYellow
528+ Write-Host (" [{0}] version already matches '{1}' - skipping tag." -f $row.RepoName , $finalTag ) - ForegroundColor DarkYellow
515529 $row.FinalTag = $finalTag
516530 $row.Skipped2 = $true
517531 continue
0 commit comments