32 lines
794 B
PowerShell
32 lines
794 B
PowerShell
param(
|
|
[string]$Remote = "origin",
|
|
[string]$Branch = "",
|
|
[switch]$SetUpstream
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
. (Join-Path $PSScriptRoot "dev-tools.ps1")
|
|
|
|
Use-LocalTooling
|
|
$credential = Import-GitCredential
|
|
if (-not $Branch) {
|
|
$Branch = (& git branch --show-current).Trim()
|
|
}
|
|
if (-not $Branch) {
|
|
throw "현재 브랜치를 찾지 못했습니다."
|
|
}
|
|
|
|
$pair = "{0}:{1}" -f $credential.Username, $credential.Password
|
|
$token = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pair))
|
|
$gitArgs = @("-c", "http.extraheader=AUTHORIZATION: Basic $token", "push")
|
|
if ($SetUpstream) {
|
|
$gitArgs += @("--set-upstream", $Remote, $Branch)
|
|
} else {
|
|
$gitArgs += @($Remote, $Branch)
|
|
}
|
|
|
|
Write-Step "git push $Remote $Branch"
|
|
& git @gitArgs
|