Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions scripts/Fix-BranchRuleset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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
}
}
Loading