Update new-branch.ps1

This commit is contained in:
Markus Fleschutz 2022-12-14 09:54:40 +01:00
parent c361acb66e
commit 846ba2d56c

View File

@ -22,12 +22,12 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
Write-Host "⏳ (1/6) Searching for Git executable... " -noNewline
Write-Host "⏳ (1/6) Searching for Git executable... " -noNewline
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
$RepoDirName = (Get-Item "$RepoDir").Name
"⏳ (2/6) Checking Git repository 📂$RepoDirName... "
Write-Host "⏳ (2/6) Checking Git repository... 📂$RepoDirName... "
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
"⏳ (3/6) Fetching updates..."
@ -37,7 +37,7 @@ try {
$CurrentBranchName = (git -C "$RepoDir" rev-parse --abbrev-ref HEAD)
if ($lastExitCode -ne "0") { throw "'git rev-parse' failed with exit code $lastExitCode" }
"⏳ (4/6) Creating branch '$NewBranchName'..."
"⏳ (4/6) Creating new branch..."
& git -C "$RepoDir" checkout -b "$NewBranchName"
if ($lastExitCode -ne "0") { throw "'git checkout -b $NewBranchName' failed with exit code $lastExitCode" }
@ -50,7 +50,7 @@ try {
if ($lastExitCode -ne "0") { throw "'git submodule update' failed with exit code $lastExitCode" }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ created new branch '$NewBranchName' (based on '$CurrentBranchName') in 📂$RepoDirName repo in $Elapsed sec."
"✔️ created new '$NewBranchName' branch in 📂$RepoDirName repository (based on '$CurrentBranchName') in $Elapsed sec."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"