Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Git plugin: add option to create new branch
Browse files Browse the repository at this point in the history
If the branch already exists, we will try to push into it.
  • Loading branch information
easybe committed Jun 1, 2021
1 parent 424086a commit 3b83454
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions AU/Plugins/Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ param(
[string]$commitStrategy = 'single',

# Branch name
[string]$Branch = 'master'
[string]$Branch = 'master',

# Create the branch if it does not exist
[switch]$CreateBranch
)

[array]$packages = if ($Force) { $Info.result.updated } else { $Info.result.pushed }
Expand All @@ -51,9 +54,14 @@ if ($User -and $Password) {
Add-Content "$env:USERPROFILE\.git-credentials" "https://${Password}:x-oauth-basic@$machine`n"
}

Write-Host "Executing git pull"
git checkout -q $Branch
git pull -q origin $Branch
if ($CreateBranch) {
Write-Host "Creating $Branch branch"
git checkout -B $Branch
} else {
Write-Host "Executing git pull"
git checkout -q $Branch
git pull -q origin $Branch
}

$gitAddArgs = @()
if (-not $AddNew)
Expand Down Expand Up @@ -92,7 +100,11 @@ else {

}
Write-Host "Pushing changes"
git push -q
if ($CreateBranch) {
git push --set-upstream origin $Branch
} else {
git push -q
}
if ($commitStrategy -eq 'atomictag') {
write-host 'Atomic Tag Push'
git push -q --tags
Expand Down

0 comments on commit 3b83454

Please sign in to comment.