Skip to content

Commit

Permalink
Merge #726
Browse files Browse the repository at this point in the history
726: Replace unmaintained difference with dissimilar r=Urhengulas a=Yatekii



Co-authored-by: Noah Hüsser <[email protected]>
Co-authored-by: Johann Hemmann <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2023
2 parents 0cb72e6 + 650c2a9 commit b120494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#726]: `defmt-decoder`: Remove difference in favor of dissimilar
- [#715]: Update `clap` to version `4`
- [#710]: Update CI
- [#706]: Satisfy clippy
Expand All @@ -28,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#678]: Satisfy clippy
- [#719]: defmt-print: fix panic

[#726]: https:/knurling-rs/defmt/pull/726
[#715]: https:/knurling-rs/defmt/pull/715
[#710]: https:/knurling-rs/defmt/pull/710
[#706]: https:/knurling-rs/defmt/pull/706
Expand Down
2 changes: 1 addition & 1 deletion decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ryu = "1"
chrono = { version = "0.4", default-features = false, features = ["alloc", "clock"] }

# logger
difference = "2"
dissimilar = "1"
log = { version = "0.4", features = ["std"] }
defmt-json-schema = { version = "0.1", path = "./defmt-json-schema" }

Expand Down
20 changes: 10 additions & 10 deletions decoder/src/log/pretty_logger.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use colored::{Color, Colorize};
use difference::{Changeset, Difference};
use dissimilar::Chunk;
use log::{Level, Log, Metadata, Record};

use std::{
Expand Down Expand Up @@ -223,7 +223,7 @@ fn color_diff(text: String) -> String {
let mut buf = lines[..nlines - 2].join("\n").bold().to_string();
buf.push('\n');

let changeset = Changeset::new(left, right, "");
let diffs = dissimilar::diff(left, right);

writeln!(
buf,
Expand All @@ -234,27 +234,27 @@ fn color_diff(text: String) -> String {
)
.ok();
write!(buf, "{}", "<".red()).ok();
for diff in &changeset.diffs {
for diff in &diffs {
match diff {
Difference::Same(s) => {
Chunk::Equal(s) => {
write!(buf, "{}", s.red()).ok();
}
Difference::Add(_) => continue,
Difference::Rem(s) => {
Chunk::Insert(_) => continue,
Chunk::Delete(s) => {
write!(buf, "{}", s.red().bold()).ok();
}
}
}
buf.push('\n');

write!(buf, "{}", ">".green()).ok();
for diff in &changeset.diffs {
for diff in &diffs {
match diff {
Difference::Same(s) => {
Chunk::Equal(s) => {
write!(buf, "{}", s.green()).ok();
}
Difference::Rem(_) => continue,
Difference::Add(s) => {
Chunk::Delete(_) => continue,
Chunk::Insert(s) => {
write!(buf, "{}", s.green().bold()).ok();
}
}
Expand Down

0 comments on commit b120494

Please sign in to comment.