Delete GHCreator and its usages (#5042)

https://github.com/Azure/azure-sdk-tools/pull/5042
This commit is contained in:
Konrad Jamrozik 2023-01-04 14:55:10 -08:00 коммит произвёл GitHub
Родитель 3bdc529e2a
Коммит f114ff8825
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 320 добавлений и 455 удалений

2
tools/github-labels/.gitignore поставляемый
Просмотреть файл

@ -1,2 +0,0 @@
# Output from the GHCreator tool
fileLog.txt

Просмотреть файл

@ -2,6 +2,12 @@
This area is focused on the management of GitHub labels for the various Azure SDK repositories, containing tools and data used for that purpose.
## Changelog
As of this PR: https://github.com/Azure/azure-sdk-tools/pull/5042
The management of GitHub labels no longer uses GHCreator. It is to be migrated to use GH CLI, per:
https://github.com/Azure/azure-sdk-tools/issues/4888#issuecomment-1369900827
## Prerequisites
- **.NET SDK:** In order to run the GHCreator tool, a version of the .NET Core SDK capable of executing an application targeting `netcoreapp3.1` is needed. The latest version of the [.NET Core SDK](https://dotnet.microsoft.com/download) is recommended.

Просмотреть файл

@ -1,60 +1,63 @@
<#
.SYNOPSIS
Deploys the set of common labels to the managed set of Azure SDK repositories.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER LabelFilePath
[optional] TThe fully-qualified path (including filename) of the CSV file that contains
the set of common label data, in GHCreator format.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to update labels for, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between updating labels for each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of common labels.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$LabelFilePath = "./common-labels.csv",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " Starting $($currentRepository)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
dotnet ./ghcreator/GHCreator.dll CreateOrUpdate $LabelFilePath $currentRepository -token $GitHubAccessToken
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($currentRepository) complete" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
<#
.SYNOPSIS
Deploys the set of common labels to the managed set of Azure SDK repositories.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER LabelFilePath
[optional] TThe fully-qualified path (including filename) of the CSV file that contains
the set of common label data, in GHCreator format.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to update labels for, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between updating labels for each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of common labels.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$LabelFilePath = "./common-labels.csv",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " Starting $($currentRepository)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
# GHCreator has been deleted by this PR: https://github.com/Azure/azure-sdk-tools/pull/5042
# Hence, this script is currently broken and needs updating to use GH CLI, per:
# https://github.com/Azure/azure-sdk-tools/issues/4888#issuecomment-1369900827
# dotnet ./ghcreator/GHCreator.dll CreateOrUpdate $LabelFilePath $currentRepository -token $GitHubAccessToken
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($currentRepository) complete" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
}

Просмотреть файл

@ -1,82 +1,86 @@
<#
.SYNOPSIS
Compares the labels for an Azure SDK repository against the set of labels common
to all repositories, outputting labels that exist only for the repository.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER RepositoryName
The full name (inlcuding owner organization) of the repository that is the
source for the labels being compared to the common set. For example, "Azure\azure-sdk-for-net".
.PARAMETER CommonLabelFilePath
[optional] The fully-qualified path (including filename) of the .csv file that contains
the set of labels common to all repositories, in GHChreate format.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$true, HelpMessage="Please provide the full name of the repository (including organization) to read labels from.", Position=1)]
[ValidateNotNullOrEmpty()]
[string]$RepositoryName,
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of common labels, in GHCreate format.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$CommonLabelFilePath = "./common-labels.csv"
)
function BuildCommonLabelHash($commonLabelFilePath)
{
$labels = [System.Collections.Generic.HashSet[string]]::new()
foreach ($line in (Get-Content $commonLabelFilePath))
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
$labels.Add($label) | Out-Null
}
}
return $labels
}
# ====================
# == Script Actions ==
# ====================
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($RepositoryName)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
$commonLabels = (BuildCommonLabelHash $CommonLabelFilePath)
$repositoryLabels = ((dotnet ./ghcreator/GHCreator.dll List Label $RepositoryName -token $GitHubAccessToken) | Select-Object -Skip 1)
$any = $false
foreach ($line in $repositoryLabels)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
if (-not $commonLabels.Contains($label))
{
Write-Host "`t$($label)"
$any = $true
}
}
}
if (-not $any)
{
Write-Host "`tThe repository contains no labels not in the common set."
}
Write-Host ""
<#
.SYNOPSIS
Compares the labels for an Azure SDK repository against the set of labels common
to all repositories, outputting labels that exist only for the repository.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER RepositoryName
The full name (inlcuding owner organization) of the repository that is the
source for the labels being compared to the common set. For example, "Azure\azure-sdk-for-net".
.PARAMETER CommonLabelFilePath
[optional] The fully-qualified path (including filename) of the .csv file that contains
the set of labels common to all repositories, in GHChreate format.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$true, HelpMessage="Please provide the full name of the repository (including organization) to read labels from.", Position=1)]
[ValidateNotNullOrEmpty()]
[string]$RepositoryName,
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of common labels, in GHCreate format.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$CommonLabelFilePath = "./common-labels.csv"
)
function BuildCommonLabelHash($commonLabelFilePath)
{
$labels = [System.Collections.Generic.HashSet[string]]::new()
foreach ($line in (Get-Content $commonLabelFilePath))
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
$labels.Add($label) | Out-Null
}
}
return $labels
}
# ====================
# == Script Actions ==
# ====================
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($RepositoryName)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
$commonLabels = (BuildCommonLabelHash $CommonLabelFilePath)
# GHCreator has been deleted by this PR: https://github.com/Azure/azure-sdk-tools/pull/5042
# Hence, this script is currently broken and needs updating to use GH CLI, per:
# https://github.com/Azure/azure-sdk-tools/issues/4888#issuecomment-1369900827
#$repositoryLabels = ((dotnet ./ghcreator/GHCreator.dll List Label $RepositoryName -token $GitHubAccessToken) | Select-Object -Skip 1)
$repositoryLabels = ""
$any = $false
foreach ($line in $repositoryLabels)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
if (-not $commonLabels.Contains($label))
{
Write-Host "`t$($label)"
$any = $true
}
}
}
if (-not $any)
{
Write-Host "`tThe repository contains no labels not in the common set."
}
Write-Host ""
Write-Host ""

Двоичные данные
tools/github-labels/ghcreator/CommandLine.dll

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
tools/github-labels/ghcreator/CsvHelper.dll

Двоичный файл не отображается.

Просмотреть файл

@ -1,136 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"GHCreator/1.0.0": {
"dependencies": {
"CommandLine.Net": "2.2.2",
"CsvHelper": "26.0.1",
"Octokit": "0.47.0",
"RateLimiter": "2.2.0"
},
"runtime": {
"GHCreator.dll": {}
}
},
"CommandLine.Net/2.2.2": {
"dependencies": {
"OutputColorizer": "2.0.0"
},
"runtime": {
"lib/netstandard2.0/CommandLine.dll": {
"assemblyVersion": "2.2.2.0",
"fileVersion": "2.2.2.0"
}
}
},
"ComposableAsync.Core/1.3.0": {
"runtime": {
"lib/netstandard2.1/ComposableAsync.Core.dll": {
"assemblyVersion": "1.1.1.0",
"fileVersion": "1.1.1.0"
}
}
},
"CsvHelper/26.0.1": {
"dependencies": {
"Microsoft.CSharp": "4.5.0"
},
"runtime": {
"lib/netstandard2.1/CsvHelper.dll": {
"assemblyVersion": "26.0.0.0",
"fileVersion": "26.0.1.0"
}
}
},
"Microsoft.CSharp/4.5.0": {},
"Octokit/0.47.0": {
"runtime": {
"lib/netstandard2.0/Octokit.dll": {
"assemblyVersion": "0.47.0.0",
"fileVersion": "0.47.0.0"
}
}
},
"OutputColorizer/2.0.0": {
"runtime": {
"lib/netstandard2.0/OutputColorizer.dll": {
"assemblyVersion": "2.0.0.0",
"fileVersion": "2.0.0.0"
}
}
},
"RateLimiter/2.2.0": {
"dependencies": {
"ComposableAsync.Core": "1.3.0"
},
"runtime": {
"lib/netstandard2.1/RateLimiter.dll": {
"assemblyVersion": "2.2.0.0",
"fileVersion": "2.2.0.0"
}
}
}
}
},
"libraries": {
"GHCreator/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"CommandLine.Net/2.2.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-CHBShT49vN9ytNP6/uJ/k1xk3s4wCnrjTfHqaO6QTA+1/cu6ypHoikiptTOgP7zr2Fjk4YyETaZiJlaQDv5Pzg==",
"path": "commandline.net/2.2.2",
"hashPath": "commandline.net.2.2.2.nupkg.sha512"
},
"ComposableAsync.Core/1.3.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-G+dQnCtP0APtOTGf3my86WMWWRWQwtmdka/B4SOBi3FmFsG1sPv7IX2KViloIyyQrRlAxP/NILXfYnGmxAxoLQ==",
"path": "composableasync.core/1.3.0",
"hashPath": "composableasync.core.1.3.0.nupkg.sha512"
},
"CsvHelper/26.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-8osOmXbxzY8S1w21t5ilmWPIlo0DrfYNUklJvLiBWcb33Sm6v5jATN0DmCsBS5KVLYdwX+vnx+FIGoGF+rJwkw==",
"path": "csvhelper/26.0.1",
"hashPath": "csvhelper.26.0.1.nupkg.sha512"
},
"Microsoft.CSharp/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kaj6Wb4qoMuH3HySFJhxwQfe8R/sJsNJnANrvv8WdFPMoNbKY5htfNscv+LHCu5ipz+49m2e+WQXpLXr9XYemQ==",
"path": "microsoft.csharp/4.5.0",
"hashPath": "microsoft.csharp.4.5.0.nupkg.sha512"
},
"Octokit/0.47.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-q1TWsMEjxG7Eb7YFrXm3MWgSPsMvPKxrIF//tuUPd9i/SS/fG7PerKr088E8AOoAFcHqMqouSrW0iAg2WgskDA==",
"path": "octokit/0.47.0",
"hashPath": "octokit.0.47.0.nupkg.sha512"
},
"OutputColorizer/2.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-a9bly2IFUOMPW97TxPupXhPiXFtmvEBeXIqhfgL4W644H37DblTxHkbzfN0l/euEF5Ep8hCRFHKpIUs2U5Khkw==",
"path": "outputcolorizer/2.0.0",
"hashPath": "outputcolorizer.2.0.0.nupkg.sha512"
},
"RateLimiter/2.2.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-GxTMVzWQqYibWZPkwitmt8N0Cd5sP3ycVZn2aC1f+yBU5B88++83npyCKiz9lvGXI/hW8iOKGiTrm3ida5Uwww==",
"path": "ratelimiter/2.2.0",
"hashPath": "ratelimiter.2.2.0.nupkg.sha512"
}
}
}

Двоичные данные
tools/github-labels/ghcreator/GHCreator.dll

Двоичный файл не отображается.

Просмотреть файл

@ -1,8 +0,0 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"/home/jesse/.dotnet/store/|arch|/|tfm|",
"/home/jesse/.nuget/packages"
]
}
}

Просмотреть файл

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}

Двоичные данные
tools/github-labels/ghcreator/Octokit.dll

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
tools/github-labels/ghcreator/RateLimiter.dll

Двоичный файл не отображается.

Просмотреть файл

@ -1,59 +1,62 @@
<#
.SYNOPSIS
Captures a snapshot of the current set of labels in the managed set of Azure SDK repositories.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER SnapshotDirectory
[optional] The directory to which snapshots should be written.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to query, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between querying each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the directory to write snapshots to.")]
[ValidateScript({Test-Path $_ -PathType 'Container'})]
[string]$SnapshotDirectory = "./repository-snapshots",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
$name = $currentRepository.Replace("Azure\", "")
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " Starting $($currentRepository)" -ForegroundColor Green
(dotnet ./ghcreator/GHCreator.dll List Label $currentRepository -token $GitHubAccessToken) | Out-File -FilePath (Join-Path $SnapshotDirectory "$($name).csv")
Write-Host " Complete" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
<#
.SYNOPSIS
Captures a snapshot of the current set of labels in the managed set of Azure SDK repositories.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER SnapshotDirectory
[optional] The directory to which snapshots should be written.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to query, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between querying each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the directory to write snapshots to.")]
[ValidateScript({Test-Path $_ -PathType 'Container'})]
[string]$SnapshotDirectory = "./repository-snapshots",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
$name = $currentRepository.Replace("Azure\", "")
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " Starting $($currentRepository)" -ForegroundColor Green
# GHCreator has been deleted by this PR: https://github.com/Azure/azure-sdk-tools/pull/5042
# Hence, this script is currently broken and needs updating to use GH CLI, per:
# https://github.com/Azure/azure-sdk-tools/issues/4888#issuecomment-1369900827
#(dotnet ./ghcreator/GHCreator.dll List Label $currentRepository -token $GitHubAccessToken) | Out-File -FilePath (Join-Path $SnapshotDirectory "$($name).csv")
Write-Host " Complete" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
}

Просмотреть файл

@ -1,103 +1,107 @@
<#
.SYNOPSIS
Scans the labels for the set managed Azure SDK repositories and compares them to the
last snapshot captured; new labels are reported to host output.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER SnapshotDirectory
[optional] The directory from which snapshots will be read. The snapshots are assumed to
be named << repository >>.csv, where the `repository` has the `Azure\` prefix removed.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to query, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between querying each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the directory read snapshots from.")]
[ValidateScript({Test-Path $_ -PathType 'Container'})]
[string]$SnapshotDirectory = "./repository-snapshots",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
function BuildSnapshotHash($snapshotFilePath)
{
$labels = [System.Collections.Generic.HashSet[string]]::new()
foreach ($line in (Get-Content $snapshotFilePath) | Select-Object -Skip 1)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
$labels.Add($label) | Out-Null
}
}
return $labels
}
# ====================
# == Script Actions ==
# ====================
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
$name = $currentRepository.Replace("Azure\", "")
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($currentRepository)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
$snapshotLabels = BuildSnapshotHash (Join-Path $SnapshotDirectory "$($name).csv")
$currentLabels = ((dotnet ./ghcreator/GHCreator.dll List Label $currentRepository -token $GitHubAccessToken) | Select-Object -Skip 1)
$any = $false
foreach ($line in $currentLabels)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
if (-not $snapshotLabels.Contains($label))
{
Write-Host "`t$($label)"
$any = $true
}
}
}
if (-not $any)
{
Write-Host "`tNo new labels found"
}
Write-Host ""
Write-Host ""
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
<#
.SYNOPSIS
Scans the labels for the set managed Azure SDK repositories and compares them to the
last snapshot captured; new labels are reported to host output.
.PARAMETER GitHubAccessToken
The personal access token of the GitHub user who this command is being run on behalf of.
.PARAMETER SnapshotDirectory
[optional] The directory from which snapshots will be read. The snapshots are assumed to
be named << repository >>.csv, where the `repository` has the `Azure\` prefix removed.
.PARAMETER RepositoryFilePath
[optional] The fully-qualified path (including filename) of the text file that contains
the set of repositories to query, with each repository appearing on a new line.
.PARAMETER DelayMinutes
[optional] The number of minutes to delay between querying each individual repository;
intended to help guard against throttling.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, HelpMessage="Please provide your GitHub access token.", Position=0)]
[ValidateNotNullOrEmpty()]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$false, HelpMessage="Please provide the directory read snapshots from.")]
[ValidateScript({Test-Path $_ -PathType 'Container'})]
[string]$SnapshotDirectory = "./repository-snapshots",
[Parameter(Mandatory=$false, HelpMessage="Please provide the path to the set of repositories.")]
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
[string]$RepositoryFilePath = "./repositories.txt",
[Parameter(Mandatory=$false, HelpMessage="Please provide the time to delay between repositories (in minutes), between 0 and 100.")]
[ValidateRange(0,100)]
[int]$DelayMinutes = 0
)
function BuildSnapshotHash($snapshotFilePath)
{
$labels = [System.Collections.Generic.HashSet[string]]::new()
foreach ($line in (Get-Content $snapshotFilePath) | Select-Object -Skip 1)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
$labels.Add($label) | Out-Null
}
}
return $labels
}
# ====================
# == Script Actions ==
# ====================
$repositories = Get-Content $RepositoryFilePath
foreach ($currentRepository in $repositories)
{
$name = $currentRepository.Replace("Azure\", "")
Write-Host " ==================================================== " -ForegroundColor Green
Write-Host " $($currentRepository)" -ForegroundColor Green
Write-Host " ==================================================== " -ForegroundColor Green
$snapshotLabels = BuildSnapshotHash (Join-Path $SnapshotDirectory "$($name).csv")
# GHCreator has been deleted by this PR: https://github.com/Azure/azure-sdk-tools/pull/5042
# Hence, this script is currently broken and needs updating to use GH CLI, per:
# https://github.com/Azure/azure-sdk-tools/issues/4888#issuecomment-1369900827
#$currentLabels = ((dotnet ./ghcreator/GHCreator.dll List Label $currentRepository -token $GitHubAccessToken) | Select-Object -Skip 1)
$currentLabels = ""
$any = $false
foreach ($line in $currentLabels)
{
if (-not [String]::IsNullOrEmpty($line))
{
[string]$label = (($line -split ",")[1])
if (-not $snapshotLabels.Contains($label))
{
Write-Host "`t$($label)"
$any = $true
}
}
}
if (-not $any)
{
Write-Host "`tNo new labels found"
}
Write-Host ""
Write-Host ""
if ($DelayMinutes -gt 0)
{
Write-Warning "Delaying for $($DelayMinutes) minutes..."
Start-Sleep -Seconds ($DelayMinutes * 60)
}
}