chore(V5.7): 增加中文提交信息校验门禁
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function ConvertFrom-Utf8Base64([string]$Value) {
|
||||
return [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value))
|
||||
}
|
||||
|
||||
function Invoke-Git([string[]]$Arguments) {
|
||||
$Output = & git @Arguments
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$Prefix = ConvertFrom-Utf8Base64 "R2l0IOWRveS7pOaJp+ihjOWksei0pe+8mg=="
|
||||
throw "$Prefix git $($Arguments -join ' ')"
|
||||
}
|
||||
return $Output
|
||||
}
|
||||
|
||||
$RepoRoot = (Invoke-Git @("rev-parse", "--show-toplevel") | Select-Object -First 1).Trim()
|
||||
$HookFile = Join-Path $RepoRoot ".githooks\commit-msg"
|
||||
if (-not (Test-Path -LiteralPath $HookFile -PathType Leaf)) {
|
||||
$Prefix = ConvertFrom-Utf8Base64 "5pyq5om+5Yiw5o+Q5Lqk6Zeo56aB77ya"
|
||||
throw "$Prefix$HookFile"
|
||||
}
|
||||
|
||||
Invoke-Git @("-C", $RepoRoot, "config", "--local", "core.hooksPath", ".githooks") | Out-Null
|
||||
$ConfiguredPath = (Invoke-Git @("-C", $RepoRoot, "config", "--local", "--get", "core.hooksPath") | Select-Object -First 1).Trim()
|
||||
if ($ConfiguredPath -ne ".githooks") {
|
||||
$Prefix = ConvertFrom-Utf8Base64 "R2l0IGhvb2tzUGF0aCDphY3nva7moKHpqozlpLHotKXvvIzlvZPliY3lgLzvvJo="
|
||||
throw "$Prefix$ConfiguredPath"
|
||||
}
|
||||
|
||||
Write-Host (ConvertFrom-Utf8Base64 "UEFTUzog5bey5Li65b2T5YmN5YWL6ZqG5ZCv55SoIEdpdCDkuK3mlofmj5DkuqTpl6jnpoHvvIhjb3JlLmhvb2tzUGF0aD0uZ2l0aG9va3PvvInjgII=")
|
||||
Reference in New Issue
Block a user