mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 10:59:14 +01:00
Improve both scripts
This commit is contained in:
parent
873ec7818f
commit
4d13b25eb2
@ -13,15 +13,14 @@ try {
|
|||||||
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" }
|
||||||
set-location "$RepoDir"
|
set-location "$RepoDir"
|
||||||
|
|
||||||
$RepoDirName = (get-item "$RepoDir").Name
|
|
||||||
"⏳ Pulling updates for Git repository 📂$RepoDirName ..."
|
|
||||||
|
|
||||||
$Null = (git --version)
|
$Null = (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" }
|
||||||
|
|
||||||
|
"🢃 Pulling updates..."
|
||||||
& git pull --recurse-submodules --jobs=4
|
& git pull --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
if ($lastExitCode -ne "0") { throw "'git pull' failed" }
|
||||||
|
|
||||||
|
$RepoDirName = (get-item "$RepoDir").Name
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec."
|
"✔️ pulled updates for Git repository 📂$RepoDirName in $Elapsed sec."
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -20,9 +20,7 @@ try {
|
|||||||
if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" }
|
if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" }
|
||||||
if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" }
|
if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" }
|
||||||
|
|
||||||
$RepoDirName = (get-item "$RepoDir").Name
|
"🢃 Fetching updates..."
|
||||||
"🢃 Fetching updates for Git repository 📂$RepoDirName ..."
|
|
||||||
|
|
||||||
& git fetch --all --recurse-submodules --jobs=4
|
& git fetch --all --recurse-submodules --jobs=4
|
||||||
if ($lastExitCode -ne "0") { throw "'git fetch -all --recurse-submodules' failed" }
|
if ($lastExitCode -ne "0") { throw "'git fetch -all --recurse-submodules' failed" }
|
||||||
|
|
||||||
@ -35,7 +33,8 @@ try {
|
|||||||
& git submodule update --init --recursive
|
& git submodule update --init --recursive
|
||||||
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
|
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
|
||||||
|
|
||||||
"✔️ switched to branch '$BranchName'"
|
$RepoDirName = (get-item "$RepoDir").Name
|
||||||
|
"✔️ switched Git repository 📂$RepoDirName to branch '$BranchName'"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user