forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to mark API as shipped (dotnet#4837)
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |