mark-shipped.ps1 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [CmdletBinding(PositionalBinding=$false)]
  2. param ()
  3. Set-StrictMode -version 2.0
  4. $ErrorActionPreference = "Stop"
  5. function MarkShipped([string]$dir) {
  6. $shippedFilePath = Join-Path $dir "PublicAPI.Shipped.txt"
  7. $shipped = Get-Content $shippedFilePath
  8. if ($null -eq $shipped) {
  9. $shipped = @()
  10. }
  11. $unshippedFilePath = Join-Path $dir "PublicAPI.Unshipped.txt"
  12. $unshipped = Get-Content $unshippedFilePath
  13. $removed = @()
  14. $removedPrefix = "*REMOVED*";
  15. Write-Host "Processing $dir"
  16. foreach ($item in $unshipped) {
  17. if ($item.Length -gt 0) {
  18. if ($item.StartsWith($removedPrefix)) {
  19. $item = $item.Substring($removedPrefix.Length)
  20. $removed += $item
  21. }
  22. else {
  23. $shipped += $item
  24. }
  25. }
  26. }
  27. $shipped | Sort-Object -Unique |Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
  28. Copy-Item eng/PublicAPI.empty.txt $unshippedFilePath
  29. }
  30. try {
  31. foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") {
  32. $dir = Split-Path -parent $file
  33. MarkShipped $dir
  34. }
  35. }
  36. catch {
  37. Write-Host $_
  38. Write-Host $_.Exception
  39. exit 1
  40. }