History

Last stretch to fix CI

GPT 5.4 committed 6 months ago

Commit 1be2d4d1 parent 3ec346b3 files · +17 −17Browse files

Unified · Split

3 files
  1. gix-diff/src/blob/unified_diff/mod.rs +2 −2
  2. gix-diff/tests/diff/blob/slider.rs +11 −11
  3. gix-imara-diff/src/lib.rs +4 −4
gix-diff/src/blob/unified_diff/mod.rs+2−2
@@ -71,7 +71,7 @@ pub trait ConsumeBinaryHunkDelegate { · 70 unmodified lines
71 fn consume_binary_hunk(&mut self, header: HunkHeader, header_str: &str, hunk: &[u8]) -> std::io::Result<()>;71 fn consume_binary_hunk(&mut self, header: HunkHeader, header_str: &str, hunk: &[u8]) -> std::io::Result<()>;
72}72}
73 73
74/// A utility trait for use in [`UnifiedDiff`].74/// A utility trait for use in [`crate::blob::UnifiedDiff`].
75pub trait ConsumeHunk {75pub trait ConsumeHunk {
76 /// The item this instance produces after consuming all hunks.76 /// The item this instance produces after consuming all hunks.
77 type Out;77 type Out;
@@ -80,7 +80,7 @@ pub trait ConsumeHunk { · 2 unmodified lines
80 /// and the original token bytes (`&[u8]`) for that line without the unified diff prefix character.80 /// and the original token bytes (`&[u8]`) for that line without the unified diff prefix character.
81 /// The `header` specifies hunk offsets, which positions the `lines` in the old and new file respectively.81 /// The `header` specifies hunk offsets, which positions the `lines` in the old and new file respectively.
82 ///82 ///
83 /// Note that [`UnifiedDiff`] will wrap its output in an [`std::io::Result`].83 /// Note that [`crate::blob::UnifiedDiff`] will wrap its output in an [`std::io::Result`].
84 /// After this method returned its first error, it will not be called anymore.84 /// After this method returned its first error, it will not be called anymore.
85 fn consume_hunk(&mut self, header: HunkHeader, lines: &[(DiffLineKind, &[u8])]) -> std::io::Result<()>;85 fn consume_hunk(&mut self, header: HunkHeader, lines: &[(DiffLineKind, &[u8])]) -> std::io::Result<()>;
86 86
gix-diff/tests/diff/blob/slider.rs+11−11
@@ -182,10 +182,10 @@ mod heuristics { · 181 unmodified lines
182 182
183 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"183 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"
184 @@ -2,1 +2,1 @@184 @@ -2,1 +2,1 @@
185 - let x = 1;185 - let x = 1;
186 + let x = 2;186 + let x = 2;
187 @@ -4,0 +4,1 @@187 @@ -4,0 +4,1 @@
188 + println!("done");188 + println!("done");
189 "#);189 "#);
190 Ok(())190 Ok(())
191 }191 }
@@ -212,10 +212,10 @@ mod heuristics { · 20 unmodified lines
212 212
213 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"213 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"
214 @@ -2,1 +2,1 @@214 @@ -2,1 +2,1 @@
215 - let x = 1;215 - let x = 1;
216 + let x = 2;216 + let x = 2;
217 @@ -4,0 +4,1 @@217 @@ -4,0 +4,1 @@
218 + println!("done");218 + println!("done");
219 "#);219 "#);
220 Ok(())220 Ok(())
221 }221 }
@@ -243,7 +243,7 @@ mod heuristics { · 21 unmodified lines
243 243
244 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"244 insta::assert_snapshot!(util::unidiff(&diff, &input), @r#"
245 @@ -4,0 +4,1 @@245 @@ -4,0 +4,1 @@
246 + println!("world");246 + println!("world");
247 "#);247 "#);
248 248
249 Ok(())249 Ok(())
@@ -311,12 +311,12 @@ mod heuristics { · 61 unmodified lines
311 let input = blob::InternedInput::new(before, after);311 let input = blob::InternedInput::new(before, after);
312 let diff = diff_with_slider_heuristics(blob::Algorithm::Histogram, &input);312 let diff = diff_with_slider_heuristics(blob::Algorithm::Histogram, &input);
313 313
314 insta::assert_snapshot!(util::unidiff(&diff, &input), @r"314 insta::assert_snapshot!(util::unidiff(&diff, &input), @"
315 @@ -3,0 +3,1 @@315 @@ -3,0 +3,1 @@
316 + y: i32,316 + y: i32,
317 @@ -7,1 +8,1 @@317 @@ -7,1 +8,1 @@
318 - Foo { x: 0 }318 - Foo { x: 0 }
319 + Foo { x: 0, y: 0 }319 + Foo { x: 0, y: 0 }
320 ");320 ");
321 321
322 Ok(())322 Ok(())
gix-imara-diff/src/lib.rs+4−4
@@ -91,13 +91,13 @@ · 90 unmodified lines
91//! [`Diff::hunks`], which returns a list of additions/removals/modifications in the91//! [`Diff::hunks`], which returns a list of additions/removals/modifications in the
92//! order that they appear in the input.92//! order that they appear in the input.
93//!93//!
94//! Finally, if the `unified_diff` feature is enabled, a diff can be printed with94//! Finally, when built with the `unified_diff` feature, this crate also provides a
95//! [`Diff::unified_diff`] to print a unified diff/patch as shown by `git diff` or `diff95//! built-in unified diff/patch formatter similar to `git diff` or `diff -u`.
96//! -u`. Note that while the unified diff has a decent amount of flexibility, it is fairly96//! Note that while the formatter has a decent amount of flexibility, it is fairly
97//! simplistic and not every formatting may be possible. It's meant to cover common97//! simplistic and not every formatting may be possible. It's meant to cover common
98//! situations but not cover every advanced use case. Instead, if you need more advanced98//! situations but not cover every advanced use case. Instead, if you need more advanced
99//! printing, build your own printer on top of the [`Diff::hunks`] iterator; for that, you can99//! printing, build your own printer on top of the [`Diff::hunks`] iterator; for that, you can
100//! take inspiration from the built-in printer.100//! take inspiration from the built-in printer implementation.
101//!101//!
102//! ```102//! ```
103//! # use gix_imara_diff::{InternedInput, Diff, Algorithm, BasicLineDiffPrinter, UnifiedDiffConfig};103//! # use gix_imara_diff::{InternedInput, Diff, Algorithm, BasicLineDiffPrinter, UnifiedDiffConfig};