Updaate switch-branch.ps1

This commit is contained in:
Markus Fleschutz 2022-09-01 10:56:49 +02:00
parent d5dcca6f3a
commit ccfa0bdc20

View File

@ -27,8 +27,9 @@ try {
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
"⏳ Step 2/6 - Checking Git repository..."
$RepoDir = Resolve-Path "$RepoDir"
$RepoDirName = (Get-Item "$RepoDir").Name
"⏳ Step 2/6 - Checking folder 📂$RepoDirName..."
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
$Result = (git status)
@ -51,9 +52,8 @@ try {
& git -C "$RepoDir" submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed with exit code $lastExitCode" }
$RepoDirName = (get-item "$RepoDir").Name
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ switched 📂$RepoDirName repo to '$BranchName' branch in $Elapsed sec"
"✔️ switched Git repo 📂$RepoDirName to $BranchName branch in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"