purge nested git batch, unignore specst

This commit is contained in:
2026-03-17 15:09:08 -06:00
parent 92000dce15
commit ec4cf523fb
4 changed files with 3876 additions and 3 deletions
-3
View File
@@ -86,9 +86,6 @@ temp/
tmp/
cache/
# SpecStory agent transcripts (can be regenerated)
.specstory/
# Updater staging/source directories (auto-downloaded)
*_updater/source/
*_updater/update_staging/
+39
View File
@@ -0,0 +1,39 @@
@echo off
:: Batch wrapper to run the PowerShell script
:: This script purges nested .git directories and redundant gitignore/gitattributes files
echo ========================================
echo Purge Nested Git Configurationsecho ========================================
echo.
:: Check if running from the correct directory
if not exist ".git" (
echo ERROR: No .git directory found in current folder.
echo Please run this script from your repository root.
pause
exit /b 1
)
echo This will remove all nested .git directories and .gitignore/.gitattributes
echo files from subdirectories, keeping only the root-level ones.
echo.
:: Show dry run first
echo Running DRY RUN first to preview changes...
echo.
powershell -ExecutionPolicy Bypass -File "%~dp0purge-nested-git.ps1" -DryRun
echo.
set /p confirm="Do you want to proceed with deletion? (y/n): "
if /i "%confirm%"=="y" (
echo.
echo Proceeding with deletion...
powershell -ExecutionPolicy Bypass -File "%~dp0purge-nested-git.ps1"
) else (
echo.
echo Cancelled. No changes were made.
)
echo.
pause
+124
View File
@@ -0,0 +1,124 @@
# PowerShell script to purge nested git configurations
# Run this from your repository root
param(
[string]$RepoPath = ".",
[switch]$DryRun = $false
)
$ErrorActionPreference = "Continue"
$itemsRemoved = @()
$itemsFailed = @()
# Get absolute path
$absPath = Resolve-Path $RepoPath
Write-Host "Scanning repository: $absPath" -ForegroundColor Cyan
Write-Host "Mode: $(if ($DryRun) { 'DRY RUN (no changes will be made)' } else { 'LIVE (files will be deleted)' })" -ForegroundColor Yellow
Write-Host ""
# Find nested .git directories (excluding root)
Write-Host "Scanning for nested .git directories..." -ForegroundColor Cyan
$gitDirs = Get-ChildItem -Path $absPath -Recurse -Directory -Force -Filter ".git" -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -ne "$absPath\.git" }
if ($gitDirs) {
Write-Host "Found $($gitDirs.Count) nested .git directory(ies):" -ForegroundColor Yellow
foreach ($dir in $gitDirs) {
$relativePath = $dir.FullName.Substring($absPath.Path.Length + 1)
Write-Host " - $relativePath" -ForegroundColor Gray
if (-not $DryRun) {
try {
Remove-Item -Recurse -Force $dir.FullName -ErrorAction Stop
$itemsRemoved += $relativePath
Write-Host " DELETED" -ForegroundColor Green
} catch {
$itemsFailed += $relativePath
Write-Host " FAILED: $_" -ForegroundColor Red
}
}
}
} else {
Write-Host "No nested .git directories found." -ForegroundColor Green
}
Write-Host ""
# Find nested .gitignore files (excluding root and .specstory)
Write-Host "Scanning for nested .gitignore files..." -ForegroundColor Cyan
$gitignores = Get-ChildItem -Path $absPath -Recurse -File -Force -Filter ".gitignore" -ErrorAction SilentlyContinue |
Where-Object {
$_.FullName -ne "$absPath\.gitignore" -and
$_.FullName -notlike "*\.specstory\*"
}
if ($gitignores) {
Write-Host "Found $($gitignores.Count) nested .gitignore file(s):" -ForegroundColor Yellow
foreach ($file in $gitignores) {
$relativePath = $file.FullName.Substring($absPath.Path.Length + 1)
Write-Host " - $relativePath" -ForegroundColor Gray
if (-not $DryRun) {
try {
Remove-Item -Force $file.FullName -ErrorAction Stop
$itemsRemoved += $relativePath
Write-Host " DELETED" -ForegroundColor Green
} catch {
$itemsFailed += $relativePath
Write-Host " FAILED: $_" -ForegroundColor Red
}
}
}
} else {
Write-Host "No nested .gitignore files found." -ForegroundColor Green
}
Write-Host ""
# Find nested .gitattributes files (excluding root)
Write-Host "Scanning for nested .gitattributes files..." -ForegroundColor Cyan
$gitattributes = Get-ChildItem -Path $absPath -Recurse -File -Force -Filter ".gitattributes" -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -ne "$absPath\.gitattributes" }
if ($gitattributes) {
Write-Host "Found $($gitattributes.Count) nested .gitattributes file(s):" -ForegroundColor Yellow
foreach ($file in $gitattributes) {
$relativePath = $file.FullName.Substring($absPath.Path.Length + 1)
Write-Host " - $relativePath" -ForegroundColor Gray
if (-not $DryRun) {
try {
Remove-Item -Force $file.FullName -ErrorAction Stop
$itemsRemoved += $relativePath
Write-Host " DELETED" -ForegroundColor Green
} catch {
$itemsFailed += $relativePath
Write-Host " FAILED: $_" -ForegroundColor Red
}
}
}
} else {
Write-Host "No nested .gitattributes files found." -ForegroundColor Green
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
# Summary
$totalFound = ($gitDirs.Count + $gitignores.Count + $gitattributes.Count)
if ($totalFound -eq 0) {
Write-Host "Repository is clean! No nested git configurations found." -ForegroundColor Green
} elseif ($DryRun) {
Write-Host "DRY RUN COMPLETE" -ForegroundColor Yellow
Write-Host "Found $totalFound item(s) that would be removed." -ForegroundColor Yellow
Write-Host "Run without -DryRun to actually delete these files." -ForegroundColor Cyan
} else {
Write-Host "PURGE COMPLETE" -ForegroundColor Green
Write-Host "Items removed: $($itemsRemoved.Count)" -ForegroundColor Green
if ($itemsFailed.Count -gt 0) {
Write-Host "Items failed: $($itemsFailed.Count)" -ForegroundColor Red
foreach ($item in $itemsFailed) {
Write-Host " - $item" -ForegroundColor Red
}
}
}
Write-Host "========================================" -ForegroundColor Cyan