Skip to content

Commit e2e6ce1

Browse files
committed
added script that allows to migrate from Unshipped to Shipped
1 parent 23502ec commit e2e6ce1

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ releaseArtifacts
118118
artifacts
119119
!build/artifacts
120120
src/Docker/**/content
121+
src/PublicAPI.empty.txt
121122

122123
!**/*.cake
123124
.DS_Store

src/mark-shipped.ps1

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

0 commit comments

Comments
 (0)