Improve create-branch.ps1

This commit is contained in:
Markus Fleschutz 2021-05-26 11:13:12 +02:00
parent a43b74e238
commit 7c64b370cf

View File

@ -19,8 +19,11 @@ try {
if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" }
if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Repository is NOT clean: $Result" }
& "$PSScriptRoot/fetch-repo.ps1"
if ($lastExitCode -ne "0") { throw "Script 'fetch-repo.ps1' failed" }
$RepoDirName = (get-item "$RepoDir").Name
"⏳ Fetching updates for Git repository 📂$RepoDirName ..."
& git fetch --all --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
& git checkout -b "$NewBranchName"
if ($lastExitCode -ne "0") { throw "'git checkout -b $NewBranchName' failed" }
@ -31,7 +34,7 @@ try {
& git submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
"✔️ created new branch 🌵$NewBranchName in Git repository $RepoDir"
"✔️ created new 🌵$NewBranchName branch in Git repository 📂$RepoDirName"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"