Update switch-branch.ps1

This commit is contained in:
Markus Fleschutz 2022-03-08 11:01:01 +01:00
parent 3d1462f2f5
commit 69b9544a21

View File

@ -19,6 +19,7 @@ param([string]$BranchName = "", [string]$RepoDir = "$PWD")
try { try {
if ($BranchName -eq "") { $BranchName = read-host "Enter name of branch to switch to" } if ($BranchName -eq "") { $BranchName = read-host "Enter name of branch to switch to" }
if ($RepoDir -eq "") { $RepoDir = read-host "Enter path to the Git repository" }
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
@ -52,7 +53,7 @@ try {
$RepoDirName = (get-item "$RepoDir").Name $RepoDirName = (get-item "$RepoDir").Name
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ switched Git repository 📂$RepoDirName to $BranchName branch in $Elapsed sec" "✔️ switched Git repo 📂$RepoDirName to $BranchName branch in $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"