mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-22 19:14:31 +03:00
Revert "remove unnecessary BString-related serde functions."
This reverts commit 3043f099b7
.
We actually need this - me removing it just means it wasn't properly
documented and clarified in the type-system as to why this is needed.
This commit is contained in:
parent
4c76e2a6ee
commit
acbd42fce3
@ -33,7 +33,7 @@ members = [
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
bstr = { version = "1.10.0", features = ["serde"] }
|
||||
bstr = "1.10.0"
|
||||
# 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 = "7dff44754e0fdc369f92221468fb953bad9be60a", default-features = false, features = ["serde"] }
|
||||
git2 = { version = "0.18.3", features = [
|
||||
|
@ -557,6 +557,7 @@ 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,
|
||||
|
@ -23,6 +23,7 @@ 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,
|
||||
|
@ -24,6 +24,7 @@ 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,
|
||||
|
@ -50,6 +50,7 @@ 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,
|
||||
|
@ -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")]
|
||||
#[serde(rename = "diff", serialize_with = "gitbutler_serde::as_string_lossy")]
|
||||
pub diff_lines: BString,
|
||||
pub binary: bool,
|
||||
pub change_type: ChangeType,
|
||||
|
@ -1,5 +1,21 @@
|
||||
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_string_lossy_vec_remote_name<S>(
|
||||
v: &[gix::remote::Name<'static>],
|
||||
s: S,
|
||||
|
Loading…
Reference in New Issue
Block a user