diff --git a/scripts/Fix-BranchRuleset.ps1 b/scripts/Fix-BranchRuleset.ps1 index 2947de0..37c68cd 100644 --- a/scripts/Fix-BranchRuleset.ps1 +++ b/scripts/Fix-BranchRuleset.ps1 @@ -12,9 +12,16 @@ .PARAMETER Repository The repository in owner/repo format. If not provided, uses the current repository. +.PARAMETER Confirm + Skip the confirmation prompt and proceed automatically. Alias: -y + .EXAMPLE .\Fix-BranchRuleset.ps1 - Inspects and fixes rulesets for the current repository + Inspects and fixes rulesets for the current repository with interactive confirmation + +.EXAMPLE + .\Fix-BranchRuleset.ps1 -y + Inspects and fixes rulesets without prompting for confirmation .EXAMPLE .\Fix-BranchRuleset.ps1 -Repository "Chris-Wolfgang/my-repo" @@ -28,7 +35,11 @@ [CmdletBinding()] param( [Parameter()] - [string]$Repository = "Chris-Wolfgang/ETL-Abstractions" + [string]$Repository = "Chris-Wolfgang/ETL-Abstractions", + + [Parameter()] + [Alias("y")] + [switch]$Confirm ) # Check if gh CLI is installed @@ -158,10 +169,14 @@ foreach ($item in $plan) { Write-Host "" # Prompt for confirmation -$response = Read-Host "Proceed with these changes? (y/N)" -if ($response -ne 'y' -and $response -ne 'Y') { - Write-Host "Cancelled. No changes were made." -ForegroundColor Yellow - exit 0 +if ($Confirm) { + Write-Host "Auto-confirmed via -Confirm flag." -ForegroundColor Green +} else { + $response = Read-Host "Proceed with these changes? (y/N)" + if ($response -ne 'y' -and $response -ne 'Y') { + Write-Host "Cancelled. No changes were made." -ForegroundColor Yellow + exit 0 + } } Write-Host "" @@ -228,6 +243,15 @@ if ($errors -gt 0) { } else { Write-Host "All changes applied successfully." -ForegroundColor Green Write-Host "" - Write-Host "Next step: Run .\Setup-BranchRuleset.ps1 to create a fresh ruleset." -ForegroundColor Cyan - Write-Host "View rulesets at: https://github.com/$Repository/settings/rules" -ForegroundColor Cyan + + # Invoke Setup-BranchRuleset.ps1 to create a fresh ruleset + $setupScript = Join-Path $PSScriptRoot "Setup-BranchRuleset.ps1" + if (Test-Path $setupScript) { + Write-Host "Running Setup-BranchRuleset.ps1 to create a fresh ruleset..." -ForegroundColor Cyan + Write-Host "" + & $setupScript -Repository $Repository + } else { + Write-Host "Setup-BranchRuleset.ps1 not found. Run it manually to create a fresh ruleset." -ForegroundColor Yellow + Write-Host "View rulesets at: https://github.com/$Repository/settings/rules" -ForegroundColor Cyan + } }