初始化: 完成Git Skill测试基线

Co-authored-by: 旅行呀~ <travelxiao@qq.com>
This commit is contained in:
2026-08-20 23:42:02 +08:00
commit 2cddf06b6c
30 changed files with 3422 additions and 0 deletions
@@ -0,0 +1,42 @@
# Interactive: encrypt a Git token with Windows DPAPI (CurrentUser).
# Run in the user's own terminal. Never print the token.
param(
[switch]$Force
)
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'common.ps1')
Ensure-GitSkillsHome
if ((Test-Path -LiteralPath $script:TokenPath) -and -not $Force) {
$answer = Read-Host 'Encrypted token already exists. Overwrite? (y/N)'
if ($answer -notmatch '^[Yy]$') {
Write-StatusLine -Key 'status' -Value 'unchanged'
exit 0
}
}
$secure = Read-Host 'Paste Gitea access token (input hidden)' -AsSecureString
if ($secure.Length -lt 1) {
throw 'Token is empty.'
}
$plain = $null
try {
$plain = ConvertFrom-SecureStringPlain -Secure $secure
if ([string]::IsNullOrWhiteSpace($plain)) {
throw 'Token is empty.'
}
$protected = Protect-SecretString -PlainText $plain
[System.IO.File]::WriteAllBytes($script:TokenPath, $protected)
}
finally {
$plain = $null
$protected = $null
}
Write-StatusLine -Key 'status' -Value 'saved'
Write-StatusLine -Key 'path' -Value $script:TokenPath
Write-Output 'token=hidden'