Skip to content

Fix: Preserve content after overwritten version (Issue #82) #84

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bordoni
Copy link
Member

@bordoni bordoni commented Aug 6, 2025

Summary

  • Fixes bug where using --overwrite-version would delete all content after the overwritten version
  • Now correctly finds the next version header and preserves content

What was broken

When using --overwrite-version with an existing version, the write command would:

  1. Try to find the next version using the same version string (which would never match)
  2. Fail to find the section end correctly
  3. Delete everything after the overwritten version

How it's fixed

  • Changed logic to search for ANY next version header pattern after current position
  • Uses generic regex patterns to match version headers regardless of specific version
  • Correctly calculates section end when next version is found

Test plan

  • Added test case for overwrite-version scenario
  • All tests passing (107 tests)
  • Manually tested with stellarwp-readme format

Fixes #82

- Fix logic to find next version header after current position
- Use generic version patterns instead of searching for same version
- Add test case for overwrite-version scenario
- Resolves issue #82 where content after overwritten version was deleted
@bordoni bordoni self-assigned this Aug 6, 2025
bordoni added 2 commits August 6, 2025 19:05
- Resolved conflicts in dist source maps
- Updated build output structure (dist/src -> dist/lib)
- Added npmignore file
- Updated TypeScript configuration
- Updated write command to append new changes to existing version content
- Previous behavior incorrectly replaced all existing content for the version
- Now correctly preserves existing changelog entries when using --overwrite-version
- Updated test expectations to match documented behavior

This addresses d4mation's comment on PR #84 about the expected behavior
of --overwrite-version matching what's documented in the README.
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.

Overwriting/merging existing Changelogs results in the rest of the file being overwritten
2 participants