mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
Update switch-branch.ps1
This commit is contained in:
parent
13ffbb9214
commit
1e74c2d15f
@ -12,7 +12,7 @@
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$BranchName = "", [string]$RepoDir = "$PWD")
|
||||
@ -35,7 +35,7 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'git status' in $RepoDir failed with exit code $lastExitCode" }
|
||||
if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" }
|
||||
|
||||
"⏳ Step 2/5: Fetching latest updates..."
|
||||
"⏳ Step 2/5: Fetching updates..."
|
||||
& git fetch --all --recurse-submodules --prune --prune-tags --force
|
||||
if ($lastExitCode -ne "0") { throw "'git fetch --all' failed with exit code $lastExitCode" }
|
||||
|
||||
@ -53,7 +53,7 @@ try {
|
||||
|
||||
$RepoDirName = (get-item "$RepoDir").Name
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ switched Git repo 📂$RepoDirName to $BranchName branch in $Elapsed sec"
|
||||
"✔️ switched repo 📂$RepoDirName to '$BranchName' branch in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user