@@ -0,0 +1,57 @@
|
||||
# Agent-safe: apply local author + signing from profile. Does not commit.
|
||||
|
||||
$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
|
||||
}
|
||||
|
||||
$gitProfile = Get-GitSkillsProfile
|
||||
if ($null -eq $gitProfile) {
|
||||
Write-StatusLine -Key 'status' -Value 'failed'
|
||||
Write-StatusLine -Key 'reason' -Value 'profile_missing'
|
||||
exit 1
|
||||
}
|
||||
|
||||
$userName = ([string]$gitProfile.userName).Trim()
|
||||
$userEmail = ([string]$gitProfile.userEmail).Trim()
|
||||
if ([string]::IsNullOrWhiteSpace($userName) -or [string]::IsNullOrWhiteSpace($userEmail)) {
|
||||
Write-StatusLine -Key 'status' -Value 'failed'
|
||||
Write-StatusLine -Key 'reason' -Value 'profile_incomplete'
|
||||
exit 1
|
||||
}
|
||||
|
||||
& git config user.name $userName
|
||||
& git config user.email $userEmail
|
||||
& git config commit.gpgsign true
|
||||
# This skill defaults to OpenPGP signing for Gitea verification (not gpg.format=ssh).
|
||||
$fmt = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'gpg.format') | Out-String).Trim()
|
||||
if ($fmt -eq 'ssh') {
|
||||
Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--unset', 'gpg.format') | Out-Null
|
||||
}
|
||||
|
||||
$signingKey = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'user.signingkey') | Out-String).Trim()
|
||||
$gpgSign = (Invoke-GitSkillsNative -FilePath git -ArgumentList @('config', '--get', 'commit.gpgsign') | Out-String).Trim()
|
||||
|
||||
$signing = 'missing'
|
||||
if (-not [string]::IsNullOrWhiteSpace($signingKey)) {
|
||||
$signing = 'present'
|
||||
}
|
||||
|
||||
Write-StatusLine -Key 'status' -Value 'ready'
|
||||
Write-StatusLine -Key 'userName' -Value $userName
|
||||
Write-StatusLine -Key 'userEmail' -Value $userEmail
|
||||
Write-StatusLine -Key 'signing' -Value $signing
|
||||
Write-StatusLine -Key 'signingkey' -Value $signingKey
|
||||
Write-StatusLine -Key 'gpgsign' -Value $gpgSign
|
||||
|
||||
$trailers = Get-CoAuthorTrailerLines -GitProfile $gitProfile
|
||||
Write-StatusLine -Key 'co_authored_by_count' -Value "$($trailers.Count)"
|
||||
foreach ($line in $trailers) {
|
||||
Write-StatusLine -Key 'co_authored_by' -Value $line
|
||||
}
|
||||
exit 0
|
||||
Reference in New Issue
Block a user