mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-10 18:44:50 +02:00
Updated clean-repo.ps1 and switch-branch.ps1
This commit is contained in:
parent
f5828c0012
commit
b702577042
@ -12,7 +12,7 @@
|
|||||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||||
⏳ (3/4) Removing untracked files in repository...
|
⏳ (3/4) Removing untracked files in repository...
|
||||||
⏳ (4/4) Removing untracked files in submodules...
|
⏳ (4/4) Removing untracked files in submodules...
|
||||||
✅ Cleaned the 📂rust repository in 2s.
|
✅ Repo 📂rust is clean now.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -22,8 +22,6 @@
|
|||||||
param([string]$path = "$PWD")
|
param([string]$path = "$PWD")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
||||||
|
|
||||||
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
|
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
|
||||||
& git --version
|
& git --version
|
||||||
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
|
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||||
@ -44,8 +42,7 @@ try {
|
|||||||
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
||||||
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||||
|
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
"✅ Repo 📂$repoName is clean now."
|
||||||
"✅ Cleaned the 📂$repoName repository in $($elapsed)s."
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
⏳ (4/6) Switching to branch 'main'...
|
⏳ (4/6) Switching to branch 'main'...
|
||||||
⏳ (5/6) Pulling remote updates...
|
⏳ (5/6) Pulling remote updates...
|
||||||
⏳ (6/6) Updating submodules...
|
⏳ (6/6) Updating submodules...
|
||||||
✅ Switched 📂rust repo to 'main' branch in 22s.
|
✅ Repo 📂rust switched to 'main' branch in 22s.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -60,7 +60,7 @@ try {
|
|||||||
if ($lastExitCode -ne 0) { throw "'git submodule update' failed with exit code $lastExitCode" }
|
if ($lastExitCode -ne 0) { throw "'git submodule update' failed with exit code $lastExitCode" }
|
||||||
|
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Switched 📂$repoDirName repo to '$branchName' branch in $($elapsed)s."
|
"✅ Repo 📂$repoDirName switched to '$branchName' branch in $($elapsed)s."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
"⚠️ Error: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||||
|
Loading…
Reference in New Issue
Block a user