Skip to content

fix(scripts): exclude auto-maintained-file-only commits from generated changelogs#490

Open
kate-shine wants to merge 4 commits into
mainfrom
u/kchuranov/release-script-readme-filter
Open

fix(scripts): exclude auto-maintained-file-only commits from generated changelogs#490
kate-shine wants to merge 4 commits into
mainfrom
u/kchuranov/release-script-readme-filter

Conversation

@kate-shine

@kate-shine kate-shine commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

The release tooling sometimes added unrelated entries to a package's CHANGELOG.

Root cause: just readme runs cargo doc2readme workspace-wide, so it regenerates every crate's README.md (the opaque [__cargo_doc2readme_dependencies_info] blob) on any change. A commit that only introduced an unrelated package therefore still touches this package's folder via that README regeneration. The path-scoped git log -- <folder> used by Write-Changelog then attributed that commit's subject to the wrong changelog.

Concrete example: commit #450 (introduce fetch_tls crate) touched only crates/templated_uri/README.md yet leaked into templated_uri's changelog.

Fix

In scripts/lib/release-flow.ps1 (Write-Changelog), exclude a commit iff every file it changed within the package folder is an auto-maintained file (README.md / CHANGELOG.md). Commits that also touch src/ etc. are kept.

Tests

Added a Write-Changelog commit filtering regression block in scripts/tests/Pester/unit/releasing/WriteChangelog.Tests.ps1:

  • a README-only commit is dropped while a real source commit is kept;
  • when every in-range commit is README-only, nothing is written.

All 150 unit/releasing Pester tests pass.

Copilot AI review requested due to automatic review settings June 11, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the crate release script’s changelog generation so that commits are only attributed to a crate when they modify at least one non auto-maintained file within that crate, preventing unrelated changelog entries caused by workspace-wide README regeneration.

Changes:

  • Collect commit hashes affecting a crate folder, then filter to commits that touch at least one non-auto-maintained file.
  • Treat README.md and CHANGELOG.md as auto-maintained for the purpose of crate changelog attribution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/release-crate.ps1 Outdated
Comment on lines +630 to +641
$autoMaintainedFiles = @('README.md', 'CHANGELOG.md')

$rawCommits = @()
foreach ($hash in $commitHashes) {
$changedFiles = @(Invoke-GitCommand -Command "show $hash --name-only --pretty=format: -- `"$crateFolder`"" -ErrorMessage "Failed to retrieve changed files for commit $hash" | Where-Object { $_ })
$hasMeaningfulChange = $false
foreach ($file in $changedFiles) {
if ($autoMaintainedFiles -notcontains (Split-Path $file -Leaf)) {
$hasMeaningfulChange = $true
break
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GHCP: Good catch — fixed in 4a30857. The filter now only treats the crate-ROOT README.md/CHANGELOG.md as auto-maintained: a file counts as auto-maintained iff its leaf is README.md/CHANGELOG.md AND its parent directory is the package folder itself. Nested docs like crates//examples/README.md now correctly count as meaningful changes. Added a regression test (keeps a commit that touches a NESTED README.md). Note: the change moved from the now-deleted scripts/release-crate.ps1 to scripts/lib/release-flow.ps1 (Write-Changelog) after the release-tooling refactor on main.

Comment thread scripts/release-crate.ps1 Outdated
Comment on lines +632 to +634
$rawCommits = @()
foreach ($hash in $commitHashes) {
$changedFiles = @(Invoke-GitCommand -Command "show $hash --name-only --pretty=format: -- `"$crateFolder`"" -ErrorMessage "Failed to retrieve changed files for commit $hash" | Where-Object { $_ })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GHCP: Done in 4a30857. Replaced the 1 git log + up-to-2 git show-per-commit pattern with a single git log --name-only --pretty=format:%H%s, parsing the record (0x1e) / unit (0x1f) separators and per-commit file lists in PowerShell. Git is now invoked once regardless of range size. Verified against real history (templated_uri v0.2.3..v0.3.0) — reproduces the expected keep/drop set.

@kate-shine kate-shine closed this Jun 11, 2026
@kate-shine kate-shine reopened this Jun 11, 2026
…d changelogs

just readme regenerates every crate's README.md workspace-wide, so a commit that only introduced an unrelated package still touches this package's folder via that regeneration. Path-scoped git log then leaked its subject into the wrong changelog. Skip commits whose only in-folder changes are README.md/CHANGELOG.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kate-shine kate-shine force-pushed the u/kchuranov/release-script-readme-filter branch from d2faf92 to c923f23 Compare June 11, 2026 08:35
@kate-shine kate-shine marked this pull request as draft June 11, 2026 08:35
…e-root docs only

Address review on PR #490:

- Only crate-root README.md/CHANGELOG.md are auto-maintained; nested files like crates/<pkg>/examples/README.md (matched solely by leaf name before) are hand-authored and must count as meaningful changes. Now match on the parent directory being the package folder.

- Replace the per-commit 'git show' calls (1 log + up to 2 show per commit) with a single 'git log --name-only', parsing record/unit separators in PowerShell, so large ranges no longer fan out into many git processes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kate-shine kate-shine marked this pull request as ready for review June 11, 2026 08:41
Copilot AI review requested due to automatic review settings June 11, 2026 08:41
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.9%. Comparing base (963e015) to head (18736f3).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #490   +/-   ##
=====================================
  Coverage   99.9%   99.9%           
=====================================
  Files        336     336           
  Lines      24829   24829           
=====================================
  Hits       24818   24818           
  Misses        11      11           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread scripts/lib/release-flow.ps1 Outdated
…t leaf

Address follow-up review on PR #490: comparing only the parent directory's leaf name to the package folder name misclassifies crates/<pkg>/<pkg>/README.md as the crate root. Build the exact repo-relative crate-root paths (crates/<pkg>/README.md, crates/<pkg>/CHANGELOG.md) from the package folder's last two segments and require a full-path match. Added a regression test for the same-leaf-and-parent nested case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 09:14
@kate-shine kate-shine enabled auto-merge (squash) June 12, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

$content | Should -Match 'nested same-named readme'
}

It 'warns and writes nothing when every in-range commit is crate-root README-only' {
Comment on lines +826 to +828
if ($hasMeaningfulChange) {
$rawCommits += $subject
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants