Skip to content

Script to mark API as shipped #4837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions eng/ApiCompatibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Mark Shipped Tool
========

This tool should be run after every supported release that has API changes. It will
merge the collection of PublicApi.Shipped.txt files with the PublicApi.Unshipped.txt
versions. This will take into account `*REMOVED*` elements when updating the files.

Usage:

``` cmd
mark-shipped.cmd
```
2 changes: 2 additions & 0 deletions eng/ApiCompatibility/mark-shipped.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\mark-shipped.ps1"
51 changes: 51 additions & 0 deletions eng/ApiCompatibility/mark-shipped.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[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 = @()
}

$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 | ?{ -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
$null | Out-File $unshippedFilePath -Encoding Ascii
}

try {
Push-Location $PSScriptRoot\..\..

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
}
finally {
Pop-Location
}