# Agent-safe repo snapshot. Never prints tokens or private keys. $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 'inside' -Value 'false' exit 0 } $branch = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('branch', '--show-current') | Out-String).Trim() $head = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('rev-parse', '--short', 'HEAD') | Out-String).Trim() $upstream = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}') | Out-String).Trim() if ($LASTEXITCODE -ne 0) { $upstream = '' } $porcelain = @(Invoke-GitSkillsNative -FilePath git -ArgumentList @('status', '--porcelain')) $dirty = if ($porcelain.Count -gt 0) { 'yes' } else { 'no' } $remoteUrl = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('remote', 'get-url', 'origin') | Out-String).Trim() if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($remoteUrl)) { $remoteUrl = '' $safeUrl = '' $protocol = '' } else { if ($remoteUrl -match '@.+@' -or $remoteUrl -match '://[^/:]+:[^@/]+@') { $safeUrl = '' } else { $safeUrl = $remoteUrl } $parsed = Parse-GitRemoteUrl -RemoteUrl $remoteUrl $protocol = [string]$parsed.Protocol } $userName = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'user.name') | Out-String).Trim() $userEmail = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'user.email') | Out-String).Trim() $gpgSign = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'commit.gpgsign') | Out-String).Trim() $signingKey = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'user.signingkey') | Out-String).Trim() Write-StatusLine -Key 'inside' -Value 'true' Write-StatusLine -Key 'branch' -Value $branch Write-StatusLine -Key 'head' -Value $head Write-StatusLine -Key 'upstream' -Value $upstream Write-StatusLine -Key 'dirty' -Value $dirty Write-StatusLine -Key 'origin_url' -Value $safeUrl Write-StatusLine -Key 'protocol' -Value $protocol Write-StatusLine -Key 'userName' -Value $userName Write-StatusLine -Key 'userEmail' -Value $userEmail Write-StatusLine -Key 'gpgsign' -Value $gpgSign Write-StatusLine -Key 'signingkey' -Value $signingKey Write-Output 'token=hidden' exit 0