mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This update improves the release notes generation process by restructuring documentation for clarity and enhancing workflows. It introduces new tools for handling GitHub issue images and attachments, along with automated tests to ensure functionality. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: N/A - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [x] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [x] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: N/A <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments The changes include updates to the release notes summarization process and workflow documentation for better clarity. New scripts for managing PR diffs, grouping, and milestone assignments have been added. Additionally, tools for downloading images and attachments from GitHub issues have been implemented, ensuring a more streamlined process. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Automated tests were added for the new GitHub issue tools, and all tests passed successfully. Manual validation included testing the new workflows and ensuring the documentation accurately reflects the changes made. ```
91 lines
2.7 KiB
PowerShell
91 lines
2.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Apply labels to PRs from a CSV file.
|
|
|
|
.DESCRIPTION
|
|
Reads a CSV with Id and Label columns and applies the specified label to each PR via GitHub CLI.
|
|
Supports dry-run mode to preview changes before applying.
|
|
|
|
.PARAMETER InputCsv
|
|
CSV file with Id and Label columns. Default: prs_to_label.csv
|
|
|
|
.PARAMETER Repo
|
|
GitHub repository (owner/name). Default: microsoft/PowerToys
|
|
|
|
.PARAMETER WhatIf
|
|
Dry run - show what would be applied without making changes.
|
|
|
|
.EXAMPLE
|
|
pwsh ./apply-labels.ps1 -InputCsv 'Generated Files/ReleaseNotes/prs_to_label.csv'
|
|
|
|
.EXAMPLE
|
|
pwsh ./apply-labels.ps1 -InputCsv 'Generated Files/ReleaseNotes/prs_to_label.csv' -WhatIf
|
|
|
|
.NOTES
|
|
Requires: gh CLI authenticated with repo write access.
|
|
|
|
Input CSV format:
|
|
Id,Label
|
|
12345,Product-Advanced Paste
|
|
12346,Product-Settings
|
|
#>
|
|
[CmdletBinding()] param(
|
|
[Parameter(Mandatory=$false)][string]$InputCsv = 'prs_to_label.csv',
|
|
[Parameter(Mandatory=$false)][string]$Repo = 'microsoft/PowerToys',
|
|
[switch]$WhatIf
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Write-Info($m){ Write-Host "[info] $m" -ForegroundColor Cyan }
|
|
function Write-Warn($m){ Write-Host "[warn] $m" -ForegroundColor Yellow }
|
|
function Write-Err($m){ Write-Host "[error] $m" -ForegroundColor Red }
|
|
function Write-OK($m){ Write-Host "[ok] $m" -ForegroundColor Green }
|
|
|
|
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) { Write-Err "GitHub CLI 'gh' not found in PATH"; exit 1 }
|
|
if (-not (Test-Path -LiteralPath $InputCsv)) { Write-Err "Input CSV not found: $InputCsv"; exit 1 }
|
|
|
|
$rows = Import-Csv -LiteralPath $InputCsv
|
|
if (-not $rows) { Write-Info "No rows in CSV."; exit 0 }
|
|
|
|
$firstCols = $rows[0].PSObject.Properties.Name
|
|
if (-not ($firstCols -contains 'Id' -and $firstCols -contains 'Label')) {
|
|
Write-Err "CSV must contain 'Id' and 'Label' columns"; exit 1
|
|
}
|
|
|
|
Write-Info "Processing $($rows.Count) label assignments..."
|
|
if ($WhatIf) { Write-Warn "DRY RUN - no changes will be made" }
|
|
|
|
$applied = 0
|
|
$skipped = 0
|
|
$failed = 0
|
|
|
|
foreach ($row in $rows) {
|
|
$id = $row.Id
|
|
$label = $row.Label
|
|
|
|
if ([string]::IsNullOrWhiteSpace($id) -or [string]::IsNullOrWhiteSpace($label)) {
|
|
Write-Warn "Skipping row with empty Id or Label"
|
|
$skipped++
|
|
continue
|
|
}
|
|
|
|
if ($WhatIf) {
|
|
Write-Info "Would apply label '$label' to PR #$id"
|
|
$applied++
|
|
continue
|
|
}
|
|
|
|
try {
|
|
gh pr edit $id --repo $Repo --add-label $label 2>&1 | Out-Null
|
|
Write-OK "Applied '$label' to PR #$id"
|
|
$applied++
|
|
} catch {
|
|
Write-Warn "Failed to apply label to PR #${id}: $_"
|
|
$failed++
|
|
}
|
|
}
|
|
|
|
Write-Info ""
|
|
Write-Info "Summary: Applied=$applied Skipped=$skipped Failed=$failed"
|