-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathpublic-api-mark-shipped.ps1
More file actions
46 lines (39 loc) · 1.58 KB
/
public-api-mark-shipped.ps1
File metadata and controls
46 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# This script merges the content of PublicAPI.Unshipped.txt files into PublicAPI.Shipped.txt.
# Run this before creating a new release and commit the changes.
# Based on https://github.com/dotnet/roslyn/blob/main/scripts/PublicApi/mark-shipped.ps1
#
# TIP: To obtain the public API diff between two releases, run:
# git diff --unified=0 --text <previous-release-tag-name> head -- **/PublicAPI.Shipped.txt
[CmdletBinding(PositionalBinding=$false)]
param ()
Set-StrictMode -version 2.0
$ErrorActionPreference = 'Stop'
function MarkShipped([string] $dir) {
$shippedFilePath = Join-Path $dir 'PublicAPI.Shipped.txt'
$shipped = Get-Content $shippedFilePath
if ($null -eq $shipped) {
$shipped = @('#nullable enable')
}
$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
}
elseif (-not $item.StartsWith('#')) {
$shipped += $item
}
}
}
$shipped | Sort-Object -Unique | Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
'#nullable enable' | Out-File $unshippedFilePath -Encoding Ascii
}
foreach ($file in Get-ChildItem -re -in 'PublicApi.Shipped.txt') {
$dir = Split-Path -parent $file
MarkShipped $dir
}