Skip to content

[release/v7.5] Update Get-ChangeLog to handle backport PRs correctly#26824

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26610-cd0628641
Feb 14, 2026
Merged

[release/v7.5] Update Get-ChangeLog to handle backport PRs correctly#26824
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26610-cd0628641

Conversation

@daxian-dbw
Copy link
Member

Backport of #26610 to release/v7.5

Triggered by @daxian-dbw on behalf of @daxian-dbw

Original CL Label: CL-BuildPackaging

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Updates Get-ChangeLog to detect backport PRs and extract real author attribution

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Successfully tested in 7.6 release. Ensures correct attribution in changelogs for backport PRs.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Improves changelog generation to properly attribute backport PRs. Only affects release tooling. Successfully backported to 7.6 branch.

@daxian-dbw daxian-dbw requested a review from a team as a code owner February 14, 2026 00:06
@daxian-dbw daxian-dbw added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Feb 14, 2026
Copilot AI review requested due to automatic review settings February 14, 2026 00:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports tooling changes to Get-ChangeLog on release/v7.5 to correctly attribute changelog entries when commits come from backport PRs (where the merge author differs from the original PR author).

Changes:

  • Detect backport PR commits via [release/vX.Y] subject prefix and extract the original author from the PR body for attribution.
  • Add a PowerShell team GitHub-login allowlist to avoid “Thanks @…” messages for internal/team authors.
  • Strip [release/vX.Y] prefixes from changelog message subjects and avoid using $input (automatic variable) in Invoke-PRBackport.

Comment on lines 329 to +342
try{
$response = Invoke-WebRequest -Uri $uri -Method Get -Headers $header -ErrorAction Ignore
} catch{}
## Always disable verbose to avoid noise when we debug this function.
$response = Invoke-RestMethod `
-Uri "https://api.github.com/repos/PowerShell/PowerShell/commits/$($commit.Hash)" `
-Headers $header `
-ErrorAction Stop `
-Verbose:$false
} catch {
## A commit could be available in ADO only. In that case, we will get status code 422 (UnprocessableEntity).
## Otherwise, let the error bubble up.
if ($_.Exception.Response.StatusCode -ne 422) {
throw
}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$response is not cleared before the commit lookup, so if the GitHub commit API call fails (e.g., 422) $response may still contain the prior commit’s data and incorrectly set AuthorGitHubLogin. Set $response = $null before the try/catch (and/or in the 422 catch path) so stale responses can’t be reused.

Copilot uses AI. Check for mistakes.
"CL-Untagged" { $clUntagged += $commit }
"CL-NotInBuild" { continue }
Default { throw "unknown tag '$cLabel' for PR: '$($commit.PullRequest)'" }
Default { throw "unknown tag '$cLabel' for PR: '$prNumber'" }
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default branch of this switch throws unknown tag '$cLabel' ..., but $cLabel is not defined anywhere in this scope. Use the actual label value being evaluated (e.g., $clLabel.Name) so the error message is accurate and doesn’t itself error/print an empty label.

Suggested change
Default { throw "unknown tag '$cLabel' for PR: '$prNumber'" }
Default { throw "unknown tag '$($clLabel.Name)' for PR: '$prNumber'" }

Copilot uses AI. Check for mistakes.
Comment on lines 281 to +299
foreach ($commit in $new_commits) {
$commitSubject = $commit.Subject
$prNumber = $commit.PullRequest
Write-Verbose "subject: $commitSubject"
Write-Verbose "authorname: $($commit.AuthorName)"
if ($commit.AuthorEmail.EndsWith("@microsoft.com") -or $powershell_team -contains $commit.AuthorName -or $Script:attribution_ignore_list -contains $commit.AuthorEmail) {
$commit.ChangeLogMessage = "- {0}" -f (Get-ChangeLogMessage $commit.Subject)

try {
$pr = Invoke-RestMethod `
-Uri "https://api.github.com/repos/PowerShell/PowerShell/pulls/$prNumber" `
-Headers $header `
-ErrorAction Stop `
-Verbose:$false ## Always disable verbose to avoid noise when we debug this function.
} catch {
## A commit may not have corresponding GitHub PRs. In that case, we will get status code 404 (Not Found).
## Otherwise, let the error bubble up.
if ($_.Exception.Response.StatusCode -ne 404) {
throw
}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$pr is not reset per loop iteration, and the REST call is attempted even when $prNumber is empty. If $prNumber is empty, the .../pulls/ endpoint can return a list of PRs; and if the call fails with 404, $pr can retain the previous iteration’s value. Initialize $pr = $null each iteration, only call the PR endpoint when $prNumber is present, and explicitly set $pr = $null when handling 404.

Copilot uses AI. Check for mistakes.
@daxian-dbw daxian-dbw merged commit 8447283 into PowerShell:release/v7.5 Feb 14, 2026
21 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.5/26610-cd0628641 branch February 14, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants