-
Notifications
You must be signed in to change notification settings - Fork 219
fix(docs): skip ms.date updates and republish for metadata-only changes #2154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,10 @@ function Set-RepoContent($repo, [string]$branchPrefix, [string]$sourceDir) | |
| } | ||
| ./New-Directory $repo.path | ||
| Get-ChildItem $sourceDir -Exclude .buildignore | Copy-Item -Destination $repo.path -Recurse | ||
| if ($Template -eq "docs") | ||
| { | ||
| Remove-DocsMetadataOnlyChanges $repo.path | ||
| } | ||
|
|
||
| # Commit changes | ||
| if ($Branch) | ||
|
|
@@ -205,6 +209,64 @@ function Set-RepoContent($repo, [string]$branchPrefix, [string]$sourceDir) | |
| Write-Host '' | ||
| } | ||
|
|
||
| function Get-DocsArticleBody([string]$content) | ||
| { | ||
| $lines = $content -split "`r?`n" | ||
| $start = 0 | ||
|
|
||
| if ($lines.Count -gt 0 -and $lines[0] -eq "---") | ||
| { | ||
| for ($i = 1; $i -lt $lines.Count; $i++) | ||
| { | ||
| if ($lines[$i] -eq "---") | ||
| { | ||
| $start = $i + 1 | ||
| break | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $ignoreLines = @( | ||
| "<!-- markdownlint-disable-next-line MD025 -->", | ||
| "<!-- prettier-ignore-start -->", | ||
| "<!-- prettier-ignore-end -->" | ||
| ) | ||
|
|
||
| $body = $lines[$start..($lines.Count - 1)] ` | ||
| | Where-Object { $ignoreLines -notcontains $_.Trim() } ` | ||
| | ForEach-Object { $_.TrimEnd() } | ||
|
|
||
| return (($body -join "`n") -replace "`n{3,}", "`n`n").Trim() | ||
|
Comment on lines
+229
to
+239
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [AI][Claude Opus 4.7] The workflow's A PR that changes only an ignore-comment or whitespace is seen as a real body change by the workflow (so
Consider a single source of truth — e.g., a small helper script the workflow |
||
| } | ||
|
Comment on lines
+212
to
+240
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [AI][Claude Opus 4.7]
Minimal coverage worth adding (paraphrasing @RolandKrummenacher's suggestion): It 'Get-DocsArticleBody strips frontmatter'
It 'Get-DocsArticleBody strips markdownlint/prettier ignore lines'
It 'Get-DocsArticleBody collapses 3+ blank lines to 2'
It 'Get-DocsArticleBody trims trailing whitespace per line'
It 'Get-DocsArticleBody returns "" for empty or frontmatter-only input'If both the workflow's |
||
|
|
||
| function Remove-DocsMetadataOnlyChanges([string]$docsPath) | ||
| { | ||
| Push-Location | ||
| Set-Location $docsPath | ||
| $repoRoot = git rev-parse --show-toplevel | ||
| Set-Location $repoRoot | ||
|
|
||
|
Comment on lines
+244
to
+248
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [AI][Claude Opus 4.7] 💡 Suggestion The function changes the process cwd ( Passing git -C $repoRoot cat-file -e "HEAD:$repoFile" 2>$null
...
$previousContent = [string]::Join("`n", (git -C $repoRoot show "HEAD:$repoFile"))
...
git -C $repoRoot restore --source HEAD -- $repoFileMinor — purely a readability/robustness improvement. |
||
| Get-ChildItem $docsPath -Recurse -Filter "*.md" | ForEach-Object { | ||
| $repoFile = [System.IO.Path]::GetRelativePath($repoRoot, $_.FullName).Replace("\", "/") | ||
| git cat-file -e "HEAD:$repoFile" 2>$null | ||
|
|
||
| if ($LASTEXITCODE -ne 0) | ||
| { | ||
| return | ||
| } | ||
|
|
||
| $previousContent = [string]::Join("`n", (git show "HEAD:$repoFile")) | ||
|
|
||
| $currentContent = Get-Content $_.FullName -Raw | ||
|
Comment on lines
+249
to
+259
|
||
|
|
||
| if ((Get-DocsArticleBody $previousContent) -eq (Get-DocsArticleBody $currentContent)) | ||
| { | ||
| git restore --source HEAD -- $repoFile | ||
|
|
||
| } | ||
| } | ||
|
|
||
| Pop-Location | ||
|
Comment on lines
+245
to
+267
|
||
| } | ||
|
|
||
| # Get version for branch name and commit message | ||
| $ver = & "$PSScriptRoot/Get-Version.ps1" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 [AI][Claude Opus 4.7] 💡 Suggestion
Edge case: if a file is frontmatter-only (closing
---is the last line),$startequals$lines.Countand$lines[$start..($lines.Count - 1)]becomes$lines[Count..(Count-1)], which PowerShell evaluates as a reversed range and returns the last element instead of an empty slice. The function would then return that line (likely empty), which happens to still compare equal across versions, so the visible blast radius is small — but the logic is wrong.Guard with a length check, e.g.:
(Existing pipeline continues from
| Where-Object ....)