Skip to content

Commit

Permalink
Add mark-shipped.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Caruso committed Sep 20, 2024
1 parent caf7ad4 commit 6d613d1
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Tools/mark-shipped.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[CmdletBinding(PositionalBinding=$false)]
param ()

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

function MarkShipped([string]$dir) {
$shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt"
$shipped = @()
$shipped += Get-Content $shippedFilePath

$unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt"
$unshipped = Get-Content $unshippedFilePath
$removed = @()
$removedPrefix = "*REMOVED*";
Write-Host "Processing $dir"

foreach ($item in $unshipped) {
if ($item.Length -gt 0) {
if ($item.StartsWith($removedPrefix)) {
$item = $item.Substring($removedPrefix.Length)
$removed += $item
}
else {
$shipped += $item
}
}
}

$shipped | Sort-Object -Unique |Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
Clear-Content $unshippedFilePath
}

try {
foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") {
$dir = Split-Path -parent $file
MarkShipped $dir
}
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}

0 comments on commit 6d613d1

Please sign in to comment.