@@ -0,0 +1,26 @@
|
||||
# Agent-safe: refresh auth for an existing remote (default origin).
|
||||
|
||||
param(
|
||||
[string]$Remote = 'origin'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'common.ps1')
|
||||
|
||||
$inside = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('rev-parse', '--is-inside-work-tree') | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or $inside -ne 'true') {
|
||||
Write-StatusLine -Key 'status' -Value 'failed'
|
||||
Write-StatusLine -Key 'reason' -Value 'not_a_git_repo'
|
||||
exit 1
|
||||
}
|
||||
|
||||
$remoteUrl = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('remote', 'get-url', $Remote) | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($remoteUrl)) {
|
||||
Write-StatusLine -Key 'status' -Value 'failed'
|
||||
Write-StatusLine -Key 'reason' -Value 'remote_missing'
|
||||
Write-StatusLine -Key 'remote' -Value $Remote
|
||||
exit 1
|
||||
}
|
||||
|
||||
& (Join-Path $PSScriptRoot 'prepare-auth.ps1') -RemoteUrl $remoteUrl -RemoteName $Remote
|
||||
exit $LASTEXITCODE
|
||||
Reference in New Issue
Block a user