Skip to content

Commit 911f12e

Browse files
committed
Replace expect by ?
1 parent 8aad7f3 commit 911f12e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gitoxide-core/src/repository/blame.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{ffi::OsStr, path::PathBuf, str::Lines};
22

3+
use anyhow::anyhow;
34
use gix::bstr::BStr;
45

56
pub fn blame_file(mut repo: gix::Repository, file: &OsStr, out: impl std::io::Write) -> anyhow::Result<()> {
@@ -13,7 +14,10 @@ pub fn blame_file(mut repo: gix::Repository, file: &OsStr, out: impl std::io::Wr
1314
.collect();
1415
let mut resource_cache = repo.diff_resource_cache_for_tree_diff()?;
1516

16-
let work_dir: PathBuf = repo.work_dir().expect("TODO").into();
17+
let work_dir: PathBuf = repo
18+
.work_dir()
19+
.ok_or_else(|| anyhow!("blame needs a workdir, but there is none"))?
20+
.into();
1721
let file_path: &BStr = gix::path::os_str_into_bstr(file)?;
1822

1923
let blame_entries = gix::blame::blame_file(
@@ -23,11 +27,10 @@ pub fn blame_file(mut repo: gix::Repository, file: &OsStr, out: impl std::io::Wr
2327
suspect.id,
2428
work_dir.clone(),
2529
file_path,
26-
)
27-
.expect("TODO");
30+
)?;
2831

2932
let absolute_path = work_dir.join(file);
30-
let file_content = std::fs::read_to_string(absolute_path).expect("TODO");
33+
let file_content = std::fs::read_to_string(absolute_path)?;
3134
let lines = file_content.lines();
3235

3336
write_blame_entries(out, lines, blame_entries)?;

0 commit comments

Comments
 (0)