mirror of
https://github.com/github/spec-kit.git
synced 2026-03-25 14:53:08 +00:00
Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/spec-kit/sessions/809a1dbf-1301-4312-b4d2-e18f9b3e8b2f
34 lines
1.0 KiB
PowerShell
34 lines
1.0 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
# Git-specific common functions for the git extension.
|
|
# Extracted from scripts/powershell/common.ps1 — contains only git-specific
|
|
# branch validation and detection logic.
|
|
|
|
function Test-HasGit {
|
|
try {
|
|
git rev-parse --show-toplevel 2>$null | Out-Null
|
|
return ($LASTEXITCODE -eq 0)
|
|
} catch {
|
|
return $false
|
|
}
|
|
}
|
|
|
|
function Test-FeatureBranch {
|
|
param(
|
|
[string]$Branch,
|
|
[bool]$HasGit = $true
|
|
)
|
|
|
|
# For non-git repos, we can't enforce branch naming but still provide output
|
|
if (-not $HasGit) {
|
|
Write-Warning "[specify] Warning: Git repository not detected; skipped branch validation"
|
|
return $true
|
|
}
|
|
|
|
if ($Branch -notmatch '^[0-9]{3}-' -and $Branch -notmatch '^\d{8}-\d{6}-') {
|
|
Write-Output "ERROR: Not on a feature branch. Current branch: $Branch"
|
|
Write-Output "Feature branches should be named like: 001-feature-name or 20260319-143022-feature-name"
|
|
return $false
|
|
}
|
|
return $true
|
|
}
|