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"