Skip to content

Commit 2a187ca

Browse files
committed
refactor
- put `Options` into the right place
1 parent bb2cec0 commit 2a187ca

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

gix/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ blob-diff = ["gix-diff/blob", "attributes"]
145145
merge = ["tree-editor", "blob-diff", "dep:gix-merge", "attributes"]
146146

147147
## Add blame command similar to `git blame`.
148-
blame = ["dep:gix-blame"]
148+
blame = ["dep:gix-blame", "blob-diff"]
149149

150150
## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.
151151
worktree-stream = ["gix-worktree-stream", "attributes"]

gix/src/repository/blame.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ use gix_ref::bstr::BStr;
33

44
use crate::{repository::blame_file, Repository};
55

6-
/// Options to be passed to [Repository::blame_file()](crate::Repository::blame_file()).
7-
#[derive(Default, Debug, Clone)]
8-
pub struct Options {
9-
/// The algorithm to use for diffing. If this is `None`, `diff.algorithm` will be used.
10-
pub diff_algorithm: Option<gix_diff::blob::Algorithm>,
11-
/// The ranges to blame in the file.
12-
pub ranges: gix_blame::BlameRanges,
13-
/// Don't consider commits before the given date.
14-
pub since: Option<gix_date::Time>,
15-
/// Determine if rename tracking should be performed, and how.
16-
pub rewrites: Option<gix_diff::Rewrites>,
17-
}
18-
196
impl Repository {
207
/// Produce a list of consecutive [`gix_blame::BlameEntry`] instances. Each `BlameEntry`
218
/// corresponds to a hunk of consecutive lines of the file at `suspect:<file_path>` that got
@@ -26,12 +13,12 @@ impl Repository {
2613
&self,
2714
file_path: &BStr,
2815
suspect: impl Into<ObjectId>,
29-
options: Options,
16+
options: blame_file::Options,
3017
) -> Result<gix_blame::Outcome, blame_file::Error> {
31-
let cache: Option<gix_commitgraph::Graph> = self.commit_graph_if_enabled()?;
18+
let cache = self.commit_graph_if_enabled()?;
3219
let mut resource_cache = self.diff_resource_cache_for_tree_diff()?;
3320

34-
let Options {
21+
let blame_file::Options {
3522
diff_algorithm,
3623
ranges,
3724
since,

gix/src/repository/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum Kind {
2121
pub mod attributes;
2222
///
2323
#[cfg(feature = "blame")]
24-
pub mod blame;
24+
mod blame;
2525
mod cache;
2626
#[cfg(feature = "worktree-mutation")]
2727
mod checkout;
@@ -97,6 +97,19 @@ mod new_commit_as {
9797
///
9898
#[cfg(feature = "blame")]
9999
pub mod blame_file {
100+
/// Options to be passed to [Repository::blame_file()](crate::Repository::blame_file()).
101+
#[derive(Default, Debug, Clone)]
102+
pub struct Options {
103+
/// The algorithm to use for diffing. If `None`, `diff.algorithm` will be used.
104+
pub diff_algorithm: Option<gix_diff::blob::Algorithm>,
105+
/// The ranges to blame in the file.
106+
pub ranges: gix_blame::BlameRanges,
107+
/// Don't consider commits before the given date.
108+
pub since: Option<gix_date::Time>,
109+
/// Determine if rename tracking should be performed, and how.
110+
pub rewrites: Option<gix_diff::Rewrites>,
111+
}
112+
100113
/// The error returned by [Repository::blame_file()](crate::Repository::blame_file()).
101114
#[derive(Debug, thiserror::Error)]
102115
#[allow(missing_docs)]

gix/tests/gix/repository/blame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn simple() -> crate::Result {
1717
fn with_options() -> crate::Result {
1818
let repo = crate::named_repo("make_blame_repo.sh")?;
1919

20-
let options = gix::repository::blame::Options {
20+
let options = gix::repository::blame_file::Options {
2121
ranges: gix::blame::BlameRanges::from_one_based_inclusive_range(1..=2)?,
2222
..Default::default()
2323
};

0 commit comments

Comments
 (0)