Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/Rulebook.Update.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,9 @@ function Get-EffectiveDiffBlock {
.DESCRIPTION
The rendering of Validate.ps1, shared by the update and the scan pull request bodies. Endpoints in the order of
-Diff (settings order).
.NOTES
The array is returned with a leading comma so that a one-element result stays an array. Callers assign it
directly or to [string[]] and never wrap the call in @(), which would nest it and print System.String[] (#75).
#>
[CmdletBinding()]
[OutputType([string[]])]
Expand Down Expand Up @@ -1226,7 +1229,9 @@ function ConvertTo-UpdateSummary {
[void]$text.AppendLine('## Effective diff').AppendLine().AppendLine($diffNote).AppendLine()
} elseif ($null -ne $Result -and @($Result.Diff).Count -gt 0) {
[void]$text.AppendLine('## Effective diff').AppendLine()
[void]$text.Append((@(Get-EffectiveDiffBlock -Diff @($Result.Diff)) -join ''))
# Get-EffectiveDiffBlock returns its array with a comma; @() around it would nest it and print System.String[] (#75).
[string[]]$blocks = Get-EffectiveDiffBlock -Diff @($Result.Diff)
[void]$text.Append(($blocks -join ''))
}
if ($Plan.ReleaseNotesShipped -and -not [string]::IsNullOrWhiteSpace($Plan.ReleaseNotes)) {
[void]$text.AppendLine('## Release notes').AppendLine().AppendLine((ConvertTo-ReleaseNotesMarkdown -Text $Plan.ReleaseNotes)).AppendLine()
Expand Down
8 changes: 8 additions & 0 deletions tests/Rulebook.Update.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,14 @@ Describe 'ConvertTo-UpdatePullRequestBody and ConvertTo-UpdateSummary' {
$summary | Should-MatchString '(?m)^## Release notes\n\n### v1\.1$'
}

It 'writes the effective diff tables into the summary, not System.String[] (#75)' {
$row = [pscustomobject]@{ Endpoint = 'recommended.default'; File = 'rulesets/recommended.ruleset.json'; Id = 'LC0031'; Before = 'Warning'; After = 'Error'; BeforeSource = 'default'; AfterSource = 'level:recommended'; AfterDetail = $null; Change = 'action'; ListedAfter = $true }
$result = [pscustomobject]@{ Result = 'pull-request'; PullRequestUrl = 'https://github.com/Contoso/rulebook/pull/3'; Fallback = $false; Diff = @($row) }
$summary = ConvertTo-UpdateSummary -Plan $plan -Result $result -Mode update
$summary | Should-MatchString '(?m)^## Effective diff\n\n### `recommended\.default` \(`rulesets/recommended\.ruleset\.json`\)\n\n\| Id \| Before \| After \| Decided by \|\n\|---\|---\|---\|---\|\n\| LC0031 \| Warning \| Error \| level:recommended \|$'
$summary | Should-NotMatchString 'System\.String\[\]'
}

It 'writes the check summary with the change table' {
$summary = ConvertTo-UpdateSummary -Plan $plan -Mode check -Message 'Updates available'
$summary | Should-MatchString '(?m)^## Template update check$'
Expand Down
Loading