mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-01 20:45:57 +03:00
chore: refactor hunks_by_filepath function to simplify code and improve readability
This commit is contained in:
parent
1cccaa6d69
commit
644a4ae3f3
@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, path};
|
||||
use std::{collections::HashMap, path, str};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use serde::Serialize;
|
||||
@ -135,12 +135,11 @@ fn hunks_by_filepath(
|
||||
}
|
||||
|
||||
match line.origin() {
|
||||
'+' | '-' | ' ' => current_diff.push_str(&format!("{}", line.origin())),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// is this a binary patch or a hunk?
|
||||
match line.origin() {
|
||||
'+' | '-' | ' ' => {
|
||||
current_diff.push_str(&format!("{}", line.origin()));
|
||||
current_diff.push_str(str::from_utf8(line.content()).unwrap());
|
||||
current_binary = false;
|
||||
}
|
||||
'B' => {
|
||||
let full_path = repository.workdir().unwrap().join(file_path);
|
||||
// save the file_path to the odb
|
||||
@ -153,7 +152,6 @@ fn hunks_by_filepath(
|
||||
}
|
||||
_ => {
|
||||
current_diff.push_str(std::str::from_utf8(line.content()).unwrap());
|
||||
current_binary = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user