updated script

This commit is contained in:
Edward R. Gonzalez 2024-10-18 16:20:48 -04:00
parent ad5ca15094
commit c6f1f50705

View File

@ -81,11 +81,25 @@ function Remove-ContentFromGitHistory {
if ($LASTEXITCODE -ne 0) { throw "Error during filter-branch operation" } if ($LASTEXITCODE -ne 0) { throw "Error during filter-branch operation" }
Write-Verbose "Cleaning up refs..." Write-Verbose "Cleaning up refs..."
# Clean up refs # Clean up refs using git directly
$for_each_ref_args = @("$fgit_format='$fmt_delete_refs'", $original_refs) $refs = & git show-ref --heads | ForEach-Object { $_.Split()[1] }
$refs_to_delete = & git $cgit_for_each_ref $for_each_ref_args foreach ($ref in $refs) {
$refs_to_delete | & git $cgit_update_ref $fgit_stdin $originalRef = "refs/original/$ref"
if ($LASTEXITCODE -ne 0) { throw "Error during ref cleanup" } if (& git show-ref --verify --quiet $originalRef) {
Write-Verbose "Deleting ref: $originalRef"
& git update-ref -d $originalRef
if ($LASTEXITCODE -ne 0) {
Write-Warning "Error deleting ref: $originalRef"
}
}
}
# Remove any remaining refs/original directory
$originalRefsPath = Join-Path $repoPath ".git\refs\original"
if (Test-Path $originalRefsPath) {
Write-Verbose "Removing refs/original directory"
Remove-Item -Recurse -Force $originalRefsPath
}
Write-Verbose "Expiring reflog..." Write-Verbose "Expiring reflog..."
# Expire reflog # Expire reflog