mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-12 21:18:17 +02:00
Update clean-repo.ps1 and switch-branch.ps1
This commit is contained in:
parent
ac4df785f2
commit
2f8620c610
@ -27,7 +27,7 @@ try {
|
|||||||
"⏳ Step 2/4 - Checking folder 📂$RepoDirName..."
|
"⏳ Step 2/4 - Checking folder 📂$RepoDirName..."
|
||||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder '$RepoDir' - maybe a typo or missing folder permissions?" }
|
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder '$RepoDir' - maybe a typo or missing folder permissions?" }
|
||||||
|
|
||||||
"⏳ Step 3/4 - Cleaning Git repository..."
|
"⏳ Step 3/4 - Cleaning Git repository from untracked files..."
|
||||||
& git -C "$RepoDir" clean -xfd -f # to delete all untracked files in the main repo
|
& git -C "$RepoDir" clean -xfd -f # to delete all untracked files in the main repo
|
||||||
if ($lastExitCode -ne "0") {
|
if ($lastExitCode -ne "0") {
|
||||||
"'git clean' failed with exit code $lastExitCode, retrying once..."
|
"'git clean' failed with exit code $lastExitCode, retrying once..."
|
||||||
@ -35,12 +35,12 @@ try {
|
|||||||
if ($lastExitCode -ne "0") { throw "'git clean' failed with exit code $lastExitCode" }
|
if ($lastExitCode -ne "0") { throw "'git clean' failed with exit code $lastExitCode" }
|
||||||
}
|
}
|
||||||
|
|
||||||
"⏳ Step 4/4 - Cleaning Git submodules..."
|
"⏳ Step 4/4 - Cleaning Git submodules from untracked files..."
|
||||||
& git -C "$RepoDir" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
& git -C "$RepoDir" 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
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ cleaned Git repo 📂$RepoDirName in $Elapsed sec"
|
"✔️ cleaned 📂$RepoDirName repo in $Elapsed sec"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -29,7 +29,7 @@ try {
|
|||||||
|
|
||||||
$RepoDir = Resolve-Path "$RepoDir"
|
$RepoDir = Resolve-Path "$RepoDir"
|
||||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||||
"⏳ Step 2/6 - Checking Git repository 📂$RepoDirName..."
|
"⏳ Step 2/6 - Checking folder 📂$RepoDirName..."
|
||||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||||
|
|
||||||
$Result = (git status)
|
$Result = (git status)
|
||||||
|
Loading…
Reference in New Issue
Block a user