feat: optimize changelog check for package.json changes#84
Conversation
2edd237 to
17753c4
Compare
- Skip changelog when only version, dev dependencies, or both are changed
17753c4 to
654b094
Compare
mcmire
left a comment
There was a problem hiding this comment.
I think this looks correct, but I had some suggestions for simplifying the changes.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
mcmire
left a comment
There was a problem hiding this comment.
A few more things I noticed, but I tested this out and everything else looks good.
There was a problem hiding this comment.
Bug: Package.json Parsing Fails on Duplicate Lines
The getDevDependencyLines function incorrectly classifies changes within package.json files. It uses findIndex to locate change lines in the full diff output, which always returns the first occurrence. If the same line content appears multiple times (e.g., a dependency change in both dependencies and devDependencies), the function misidentifies its true position. This leads to an incorrect determination of whether a change is within the devDependencies section, potentially causing erroneous changelog requirements (e.g., requiring an entry for a pure dev dependency update) or incorrectly skipping other changes.
src/changelog-check.ts#L150-L163
github-tools/src/changelog-check.ts
Lines 150 to 163 in 5ad7e40
Bug: Version Parsing Errors Cause Script Crash
The isVersionDowngrade function does not handle errors when creating SemVer objects from oldVersion or newVersion. If these version strings are invalid semantic versions, the SemVer constructor throws an unhandled exception, crashing the script. This bypasses the error handling in the calling analyzePackageJsonChanges function.
src/changelog-check.ts#L174-L180
github-tools/src/changelog-check.ts
Lines 174 to 180 in 5ad7e40
Was this report helpful? Give feedback by reacting with 👍 or 👎
Description
This PR significantly improves the changelog check workflow by optimizing package.json change detection, adding support for skipping changelog requirements in common scenarios, and implementing smart changelog section detection for release PRs.
🎯 Enhanced Skip Logic
Fixes
package.jsonas changed if it only has changes todevDependencies#77release_candidateorrcflag that checks for entries to be placed in given version rather than Unreleased #78Examples
✅ Will be skipped (no changelog required):
❌ Will require changelog: