Skip to content

Commit 2c77a09

Browse files
Respect case-sensitive branches in release PR associations
1 parent 0a0119c commit 2c77a09

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎.github/actions/Get-PSModuleSettings/src/Get-PSModuleSettings.Helpers.psm1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function Select-PullRequestForPush {
105105

106106
$PullRequest |
107107
Where-Object {
108-
$_.Base.Ref -eq $DefaultBranch -and
108+
$_.Base.Ref -ceq $DefaultBranch -and
109109
-not [string]::IsNullOrWhiteSpace($_.merged_at) -and
110110
$_.merge_commit_sha -eq $CommitSha
111111
} |
@@ -161,7 +161,7 @@ function Get-DiscardedReleasePullRequest {
161161

162162
foreach ($candidate in ($PullRequest | Where-Object { $null -ne $_ })) {
163163
$isMergedToDefaultBranch = (
164-
$candidate.Base.Ref -eq $DefaultBranch -and
164+
$candidate.Base.Ref -ceq $DefaultBranch -and
165165
-not [string]::IsNullOrWhiteSpace($candidate.merged_at)
166166
)
167167
if (-not $isMergedToDefaultBranch) { continue }

‎.github/actions/Get-PSModuleSettings/tests/Get-PSModuleSettings.Helpers.Tests.ps1‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ Describe 'Resolve-WorkflowEventRouting' {
8383
}
8484

8585
Describe 'Select-PullRequestForPush' {
86+
It 'does not select a merged PR targeting a differently cased branch' {
87+
$request = [pscustomobject]@{
88+
Base = [pscustomobject]@{ Ref = 'Main' }; merged_at = '2026-09-01T00:00:00Z'; merge_commit_sha = 'pushed-sha'
89+
}
90+
91+
Select-PullRequestForPush -PullRequest @($request) -DefaultBranch main -CommitSha pushed-sha |
92+
Should -BeNullOrEmpty
93+
}
94+
8695
It 'selects the merged PR whose merge commit matches the pushed commit' {
8796
$pullRequests = @(
8897
[pscustomobject]@{
@@ -357,6 +366,14 @@ Describe 'Resolve-ReleasePullRequest' {
357366
}
358367

359368
Describe 'Get-DiscardedReleasePullRequest' {
369+
It 'does not reject a release based on another differently cased branch' {
370+
$request = [pscustomobject]@{
371+
Base = [pscustomobject]@{ Ref = 'Main' }; merged_at = '2026-09-01T00:00:00Z'; merge_commit_sha = 'other-sha'
372+
}
373+
374+
@(Get-DiscardedReleasePullRequest -PullRequest @($request) -DefaultBranch main -CommitSha pushed-sha).Count |
375+
Should -Be 0
376+
}
360377
It 'reports a merged default-branch pull request that does not match the released commit' {
361378
$pullRequests = @(
362379
[pscustomobject]@{

0 commit comments

Comments
 (0)