CD / tools /git /commit-scope.ps1
tkadkghdlf's picture
Sync from GitHub via hub-sync
f711f7f verified
Raw
History Blame Contribute Delete
541 Bytes
param(
[Parameter(Mandatory = $true)]
[string]$Message,
[Parameter(Mandatory = $true)]
[string[]]$Scope
)
$ErrorActionPreference = "Stop"
foreach ($path in $Scope) {
Write-Host "[commit-scope] stage $path"
git add -- $path
if ($LASTEXITCODE -ne 0) {
throw "git add failed for scope: $path"
}
}
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
throw "No staged changes in selected scope."
}
git commit -m $Message
if ($LASTEXITCODE -ne 0) {
throw "git commit failed."
}
Write-Host "[commit-scope] completed"