From 6d613d13e4793e0506b33085a7952ce26ab5a2e7 Mon Sep 17 00:00:00 2001 From: Keegan Caruso Date: Mon, 9 Sep 2024 19:55:04 -0700 Subject: [PATCH] Add mark-shipped.ps1 --- Tools/mark-shipped.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Tools/mark-shipped.ps1 diff --git a/Tools/mark-shipped.ps1 b/Tools/mark-shipped.ps1 new file mode 100644 index 0000000000..164dbc097a --- /dev/null +++ b/Tools/mark-shipped.ps1 @@ -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 +}