Skip to content

Commit 24c4082

Browse files
committed
Add BlameEntry::from_unblamed_hunk
1 parent 39cc3ed commit 24c4082

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

gix-blame/src/lib.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ impl BlameEntry {
134134
}
135135
}
136136
}
137+
138+
fn from_unblamed_hunk(unblamed_hunk: &UnblamedHunk, commit_id: ObjectId) -> Self {
139+
Self {
140+
range_in_blamed_file: unblamed_hunk.range_in_blamed_file.clone(),
141+
range_in_original_file: unblamed_hunk.range_in_destination.clone(),
142+
commit_id,
143+
}
144+
}
137145
}
138146

139147
#[derive(Clone, Debug, PartialEq)]
@@ -744,16 +752,11 @@ pub fn blame_file<E>(
744752
// remaining lines to it, even though we don’t explicitly check whether that is true
745753
// here. We could perhaps use `needed_to_obtain` to compare `suspect` against an empty
746754
// tree to validate this assumption.
747-
out.extend(hunks_to_blame.iter().map(|hunk| {
748-
BlameEntry::new(
749-
hunk.range_in_blamed_file.clone(),
750-
// TODO
751-
// I don’t know whether it is correct to use `range_in_destination` for
752-
// this purpose.
753-
hunk.range_in_destination.clone(),
754-
suspect,
755-
)
756-
}));
755+
out.extend(
756+
hunks_to_blame
757+
.iter()
758+
.map(|hunk| BlameEntry::from_unblamed_hunk(hunk, suspect)),
759+
);
757760

758761
hunks_to_blame = vec![];
759762

@@ -777,16 +780,11 @@ pub fn blame_file<E>(
777780
gix_diff::tree::recorder::Change::Addition { .. } => {
778781
// Every line that has not been blamed yet on a commit, is expected to have been
779782
// added when the file was added to the repository.
780-
out.extend(hunks_to_blame.iter().map(|hunk| {
781-
BlameEntry::new(
782-
hunk.range_in_blamed_file.clone(),
783-
// TODO
784-
// I don’t know whether it is correct to use `range_in_destination` for
785-
// this purpose.
786-
hunk.range_in_destination.clone(),
787-
suspect,
788-
)
789-
}));
783+
out.extend(
784+
hunks_to_blame
785+
.iter()
786+
.map(|hunk| BlameEntry::from_unblamed_hunk(hunk, suspect)),
787+
);
790788

791789
hunks_to_blame = vec![];
792790

0 commit comments

Comments
 (0)