chore: install-git-hooks.ps1 for Windows
This commit is contained in:
@@ -165,7 +165,7 @@ bash -n ./ssh-monitor
|
||||
|
||||
## Релизный архив
|
||||
|
||||
Версия задаётся в **`SSH_MONITOR_VERSION`** в файле **`ssh-monitor`** и дублируется в **`version.txt`** (та же строка, что в шапке README). Модуль **`sac-client.sh`** использует ту же версию для SAC `product_version`. **Release manifest** (`release/manifest-*.json`): [docs/release-manifest.ru.md](docs/release-manifest.ru.md) — после clone выполните `./contrib/install-git-hooks.sh` (автогенерация при bump версии).
|
||||
Версия задаётся в **`SSH_MONITOR_VERSION`** в файле **`ssh-monitor`** и дублируется в **`version.txt`** (та же строка, что в шапке README). Модуль **`sac-client.sh`** использует ту же версию для SAC `product_version`. **Release manifest** (`release/manifest-*.json`): [docs/release-manifest.ru.md](docs/release-manifest.ru.md) — после clone: `.\contrib\install-git-hooks.ps1` (Windows) или `./contrib/install-git-hooks.sh` (Linux/Git Bash).
|
||||
|
||||
Сборка tarball из текущего git-дерева:
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# Install git hooks + local manifest wrappers (not committed to git).
|
||||
# Run from repo root: .\contrib\install-git-hooks.ps1
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$HookSrc = Join-Path $Root "contrib\hooks\pre-commit"
|
||||
$HookDst = Join-Path $Root ".git\hooks\pre-commit"
|
||||
$LocalDir = Join-Path $Root ".local"
|
||||
$LocalScript = Join-Path $LocalDir "build-release-manifest.ps1"
|
||||
$LocalScriptSh = Join-Path $LocalDir "build-release-manifest.sh"
|
||||
|
||||
if (-not (Test-Path (Join-Path $Root ".git"))) {
|
||||
throw "Not a git repository: $Root"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $HookSrc)) {
|
||||
throw "Missing hook file: $HookSrc"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path $HookDst) | Out-Null
|
||||
Copy-Item -Force $HookSrc $HookDst
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $LocalDir | Out-Null
|
||||
|
||||
@'
|
||||
# Local manifest wrapper (gitignored). Manual generation on Windows.
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = git -C "$PSScriptRoot\.." rev-parse --show-toplevel 2>$null
|
||||
if (-not $Root) {
|
||||
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
}
|
||||
$py = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $py) { $py = Get-Command python3 -ErrorAction SilentlyContinue }
|
||||
if (-not $py) { throw "python not found in PATH" }
|
||||
& $py.Source (Join-Path $Root "contrib\manifest\generate.py") @args
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
'@ | Set-Content -Path $LocalScript -Encoding UTF8
|
||||
|
||||
@'
|
||||
#!/bin/bash
|
||||
# Local manifest wrapper (gitignored). Git Bash.
|
||||
set -euo pipefail
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
exec python3 "$ROOT/contrib/manifest/generate.py" "$@"
|
||||
'@ | Set-Content -Path $LocalScriptSh -Encoding ASCII -NoNewline
|
||||
Add-Content -Path $LocalScriptSh -Value "`n" -NoNewline
|
||||
|
||||
Write-Host "OK: pre-commit hook -> $HookDst"
|
||||
Write-Host "OK: manual script (PS) -> $LocalScript"
|
||||
Write-Host "OK: manual script (sh) -> $LocalScriptSh"
|
||||
Write-Host ""
|
||||
Write-Host "Manual: .\.local\build-release-manifest.ps1"
|
||||
Write-Host " python contrib\manifest\generate.py"
|
||||
Write-Host "Pre-commit runs on version bump (python required in PATH)."
|
||||
@@ -28,4 +28,4 @@ chmod +x "$HOOK_DST"
|
||||
|
||||
echo "OK: pre-commit hook → $HOOK_DST"
|
||||
echo "OK: ручной скрипт → $LOCAL_SCRIPT (в .gitignore, не уйдёт в Gitea/GitHub)"
|
||||
echo "После clone выполните: ./contrib/install-git-hooks.sh"
|
||||
echo "После clone: ./contrib/install-git-hooks.sh или .\\contrib\\install-git-hooks.ps1 (Windows)"
|
||||
|
||||
@@ -6,20 +6,29 @@
|
||||
|
||||
Один раз после clone:
|
||||
|
||||
**Linux / Git Bash:**
|
||||
```bash
|
||||
./contrib/install-git-hooks.sh
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
.\contrib\install-git-hooks.ps1
|
||||
```
|
||||
|
||||
При коммите, если изменились **`version.txt`**, **`SSH_MONITOR_VERSION`** в `ssh-monitor` или любой из агентских файлов (`ssh-monitor`, `*.sh` из списка manifest), **pre-commit** вызовет `contrib/manifest/generate.py` и добавит `release/manifest-{версия}.json` в коммит.
|
||||
|
||||
## Ручная генерация (локально)
|
||||
|
||||
Скрипт **`.local/build-release-manifest.sh`** создаётся `install-git-hooks.sh` и **не коммитится** (см. `.gitignore`).
|
||||
Скрипты **`.local/build-release-manifest.ps1`** (Windows) и **`.local/build-release-manifest.sh`** (Git Bash) создаются установщиком и **не коммитятся** (см. `.gitignore`).
|
||||
|
||||
```powershell
|
||||
.\.local\build-release-manifest.ps1
|
||||
.\.local\build-release-manifest.ps1 2.2.3-SAC
|
||||
```
|
||||
|
||||
```bash
|
||||
./.local/build-release-manifest.sh
|
||||
./.local/build-release-manifest.sh 2.2.3-SAC
|
||||
git add release/manifest-2.2.3-SAC.json
|
||||
```
|
||||
|
||||
Ядро генерации в репозитории: `contrib/manifest/generate.py` (используется hook и локальным wrapper).
|
||||
|
||||
Reference in New Issue
Block a user