remove unnecessary BString-related serde functions.

They are supported when the respective bstring feature is used.
This commit is contained in:
Sebastian Thiel 2024-08-08 17:20:32 +02:00
parent 8ed90644a1
commit 3043f099b7
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B
15 changed files with 10 additions and 30 deletions

View File

@ -33,6 +33,7 @@ members = [
resolver = "2"
[workspace.dependencies]
bstr = { version = "1.10.0", features = ["serde"] }
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
gix = { git = "https://github.com/Byron/gitoxide", rev = "29898e3010bd3332418c683f2ac96aff5c8e72fa", default-features = false, features = [] }
git2 = { version = "0.18.3", features = [

View File

@ -26,7 +26,7 @@ gitbutler-fs.workspace = true
gitbutler-diff.workspace = true
gitbutler-operating-modes.workspace = true
serde = { workspace = true, features = ["std"] }
bstr = "1.10.0"
bstr.workspace = true
diffy = "0.4.0"
hex = "0.4.3"
regex = "1.10"

View File

@ -347,7 +347,6 @@ pub struct BranchListing {
pub name: BranchIdentity,
/// This is a list of remotes that this branch can be found on (e.g. `origin`, `upstream` etc.),
/// by collecting remotes from all local branches with the same identity that have a tracking setup.
#[serde(serialize_with = "gitbutler_serde::as_string_lossy_vec")]
pub remotes: Vec<BString>,
/// The branch may or may not have a virtual branch associated with it.
pub virtual_branch: Option<VirtualBranchReference>,
@ -573,7 +572,6 @@ pub struct CommitEntry {
/// If the commit is referencing a specific change, this is its change id
pub change_id: Option<String>,
/// The commit message
#[serde(serialize_with = "gitbutler_serde::as_string_lossy")]
pub description: BString,
/// The timestamp of the commit in milliseconds
pub created_at: u128,

View File

@ -23,7 +23,6 @@ use crate::{
pub struct VirtualBranchCommit {
#[serde(with = "gitbutler_serde::oid")]
pub id: git2::Oid,
#[serde(serialize_with = "gitbutler_serde::as_string_lossy")]
pub description: BString,
pub created_at: u128,
pub author: Author,

View File

@ -24,7 +24,6 @@ use serde::Serialize;
#[serde(rename_all = "camelCase")]
pub struct VirtualBranchHunk {
pub id: String,
#[serde(serialize_with = "gitbutler_serde::as_string_lossy")]
pub diff: BString,
pub modified_at: u128,
pub file_path: PathBuf,

View File

@ -50,7 +50,6 @@ pub struct RemoteBranchData {
#[serde(rename_all = "camelCase")]
pub struct RemoteCommit {
pub id: String,
#[serde(serialize_with = "gitbutler_serde::as_string_lossy")]
pub description: BString,
pub created_at: u128,
pub author: Author,

View File

@ -18,7 +18,7 @@ gitbutler-diff.workspace = true
itertools = "0.13"
toml = "0.8.15"
serde = { workspace = true, features = ["std"] }
bstr = "1.10.0"
bstr.workspace = true
md5 = "0.7.0"
hex = "0.4.3"
tracing = "0.1.40"

View File

@ -7,5 +7,5 @@ publish = false
[dependencies]
git2.workspace = true
bstr = "1.10.0"
bstr.workspace = true
uuid.workspace = true

View File

@ -7,7 +7,7 @@ publish = false
[dependencies]
git2.workspace = true
bstr = "1.10.0"
bstr.workspace = true
md5 = "0.7.0"
anyhow = "1.0.86"
hex = "0.4.3"

View File

@ -49,7 +49,7 @@ pub struct GitHunk {
pub new_start: u32,
pub new_lines: u32,
/// The `+`, `-` or ` ` prefixed lines of the diff produced by `git2`, along with their line separator.
#[serde(rename = "diff", serialize_with = "gitbutler_serde::as_string_lossy")]
#[serde(rename = "diff")]
pub diff_lines: BString,
pub binary: bool,
pub change_type: ChangeType,

View File

@ -7,7 +7,7 @@ publish = false
[dependencies]
serde = { workspace = true, features = ["std"]}
bstr = "1.10.0"
bstr.workspace = true
anyhow = "1.0.86"
gix = { workspace = true, features = ["dirwalk", "credentials", "parallel"] }
walkdir = "2.5.0"

View File

@ -9,7 +9,7 @@ publish = false
git2.workspace = true
gix.workspace = true
anyhow = "1.0.86"
bstr = "1.10.0"
bstr.workspace = true
tokio = { workspace = true, features = [ "rt-multi-thread", "rt", "macros", "sync" ] }
gitbutler-git.workspace = true
tracing = "0.1.40"

View File

@ -8,4 +8,4 @@ publish = false
[dependencies]
git2.workspace = true
serde = { workspace = true, features = ["std"]}
bstr = "1.10.0"
bstr.workspace = true

View File

@ -1,21 +1,5 @@
use bstr::{BString, ByteSlice};
use serde::Serialize;
pub fn as_string_lossy<S>(v: &BString, s: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
v.to_str_lossy().serialize(s)
}
pub fn as_string_lossy_vec<S>(v: &[BString], s: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let vec: Vec<String> = v.iter().map(|v| v.to_string()).collect();
vec.serialize(s)
}
pub fn as_time_seconds_from_unix_epoch<S>(v: &git2::Time, s: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,

View File

@ -8,4 +8,4 @@ publish = false
[dependencies]
url = { version = "2.5.2", features = ["serde"] }
thiserror.workspace = true
bstr = "1.10.0"
bstr.workspace = true