Skip to content

Commit 4d3a6b1

Browse files
committed
refactor
- rename `v0_2` to `v2` - adjust tests to use more of `insta` - feature-gate v2 and let only tests activate the feature.
1 parent 8228fc0 commit 4d3a6b1

File tree

6 files changed

+303
-274
lines changed

6 files changed

+303
-274
lines changed

gix-diff/Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,20 @@ autotests = false
1515
[features]
1616
default = ["blob", "index"]
1717
## Enable diffing of blobs using imara-diff.
18-
blob = ["dep:imara-diff", "dep:imara-diff-v0_2", "dep:gix-filter", "dep:gix-worktree", "dep:gix-path", "dep:gix-fs", "dep:gix-command", "dep:gix-tempfile", "dep:gix-trace", "dep:gix-traverse"]
18+
blob = [
19+
"dep:imara-diff",
20+
"dep:gix-filter",
21+
"dep:gix-worktree",
22+
"dep:gix-path",
23+
"dep:gix-fs",
24+
"dep:gix-command",
25+
"dep:gix-tempfile",
26+
"dep:gix-trace",
27+
"dep:gix-traverse"
28+
]
29+
## An experimental use of the v0.2 branch of `imara-diff` to allow trying it out, and for writing tests against it more easily.
30+
## We will decide later how it should actually be exposed.
31+
blob-experimental = ["dep:imara-diff-v2"]
1932
## Enable diffing of two indices, which also allows for a generic rewrite tracking implementation.
2033
index = ["dep:gix-index", "dep:gix-pathspec", "dep:gix-attributes"]
2134
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
@@ -43,7 +56,7 @@ gix-traverse = { version = "^0.49.0", path = "../gix-traverse", optional = true
4356

4457
thiserror = "2.0.17"
4558
imara-diff = { version = "0.1.8", optional = true }
46-
imara-diff-v0_2 = { version = "0.2.0", optional = true, package = "imara-diff" }
59+
imara-diff-v2 = { version = "0.2.0", optional = true, package = "imara-diff" }
4760
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }
4861
getrandom = { version = "0.2.8", optional = true, default-features = false, features = ["js"] }
4962
bstr = { version = "1.12.0", default-features = false }

gix-diff/src/blob/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ pub use imara_diff::*;
99
///
1010
/// This module provides access to the v0.2 API of imara-diff, which includes
1111
/// support for Git's slider heuristics to produce more intuitive diffs.
12-
pub mod v0_2 {
13-
pub use imara_diff_v0_2::*;
14-
}
12+
#[cfg(feature = "blob-experimental")]
13+
pub use imara_diff_v2 as v2;
1514

1615
/// Compute a diff with Git's slider heuristics to produce more intuitive diffs.
1716
///
18-
/// This function uses `imara-diff` v0.2 which provides the [`v0_2::Diff`] structure
17+
/// This function uses `imara-diff` v0.2 which provides the [`v2::Diff`] structure
1918
/// that supports postprocessing with slider heuristics. The slider heuristics move
2019
/// diff hunks to more intuitive locations based on indentation and other factors,
2120
/// resulting in diffs that are more readable and match Git's output more closely.
2221
///
2322
/// # Examples
2423
///
2524
/// ```
26-
/// use gix_diff::blob::{diff_with_slider_heuristics, v0_2::{Algorithm, InternedInput}};
25+
/// use gix_diff::blob::{diff_with_slider_heuristics, v2::{Algorithm, InternedInput}};
2726
///
2827
/// let before = "fn foo() {\n let x = 1;\n}\n";
2928
/// let after = "fn foo() {\n let x = 2;\n}\n";
@@ -35,11 +34,9 @@ pub mod v0_2 {
3534
/// assert_eq!(diff.count_removals(), 1);
3635
/// assert_eq!(diff.count_additions(), 1);
3736
/// ```
38-
pub fn diff_with_slider_heuristics<T: AsRef<[u8]>>(
39-
algorithm: v0_2::Algorithm,
40-
input: &v0_2::InternedInput<T>,
41-
) -> v0_2::Diff {
42-
let mut diff = v0_2::Diff::compute(algorithm, input);
37+
#[cfg(feature = "blob-experimental")]
38+
pub fn diff_with_slider_heuristics<T: AsRef<[u8]>>(algorithm: v2::Algorithm, input: &v2::InternedInput<T>) -> v2::Diff {
39+
let mut diff = v2::Diff::compute(algorithm, input);
4340
diff.postprocess_lines(input);
4441
diff
4542
}

gix-diff/tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ name = "diff"
1717
path = "diff/main.rs"
1818

1919
[dev-dependencies]
20-
gix-diff = { path = ".." }
20+
gix-diff = { path = "..", features = ["blob-experimental"] }
2121
gix-index = { path = "../../gix-index" }
2222
gix-pathspec = { path = "../../gix-pathspec" }
2323
gix-hash = { path = "../../gix-hash" }

gix-diff/tests/diff/blob/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub(crate) mod pipeline;
22
mod platform;
33
mod slider;
4-
mod slider_heuristics;
54
mod unified_diff;
5+
mod v2;

gix-diff/tests/diff/blob/slider_heuristics.rs

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)