Count lines only if file is valid utf-8
This commit is contained in:
parent
7b50e1de2c
commit
11c97ab4a2
1 changed files with 3 additions and 2 deletions
|
|
@ -24,10 +24,11 @@ fn count_lines(repo: &Repository, commit: &Commit) -> anyhow::Result<usize> {
|
|||
if matches!(entry.mode, EntryMode::Blob | EntryMode::BlobExecutable) {
|
||||
let object = repo.find_object(entry.oid)?;
|
||||
let data = object.detach().data;
|
||||
let text = String::from_utf8(data)?;
|
||||
if let Ok(text) = String::from_utf8(data) {
|
||||
lines += text.lines().count();
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(lines)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue