Skip to content
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

diff is noisy if you insert new paragraphs into a changelog #755

Closed
sourcefrog opened this issue Feb 25, 2024 · 0 comments · Fixed by #756
Closed

diff is noisy if you insert new paragraphs into a changelog #755

sourcefrog opened this issue Feb 25, 2024 · 0 comments · Fixed by #756

Comments

@sourcefrog
Copy link
Contributor

In cargo-mutants Cargo.toml I have cargo-release text replacement set up like this:

[workspace.metadata.release]
pre-release-replacements = [
    { "file" = "NEWS.md", search = "## Unreleased", replace = "$0\n\n## {{version}}", exactly = 1 },
]

That is to say it inserts a new version header but leaves an "Unreleased" section at the top.

This works (yay) but I initially thought that it did not, because the displayed diff shows every later paragraph being changed:

.... many lines
@@ -565,2 +565 @@
-- Functions that should not be mutated can be marked with `#[mutants::skip]`
-  from the [`mutants`](https://crates.io/crates/mutants) helper crate.
+## 0.0.2
@@ -568 +567,2 @@
-## 0.0.1
+- Functions that should not be mutated can be marked with `#[mutants::skip]`
+  from the [`mutants`](https://crates.io/crates/mutants) helper crate.
@@ -570 +570,3 @@
-First release.
+## 0.0.1
+
+First release.

I think this is because the diff code you're using isn't smart about looking for inserted lines.

It looks like you're using difflib 0.4. I would have guessed it would do better on this, but maybe not. Personally I have used https://crates.io/crates/similar in cargo-mutants and it does seem to get this kind of thing right. I will have a quick look.

sourcefrog added a commit to sourcefrog/cargo-release that referenced this issue Feb 25, 2024
Gives much better diffs when lines are inserted

Fixes crate-ci#755
sourcefrog added a commit to sourcefrog/cargo-release that referenced this issue Feb 27, 2024
Gives much better diffs when lines are inserted

Fixes crate-ci#755
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 a pull request may close this issue.

1 participant