Skip to content

Commit e0ff0ad

Browse files
committed
Also translate branch-metadata, introducing the new version of it.
1 parent 88752d3 commit e0ff0ad

File tree

6 files changed

+673
-493
lines changed

6 files changed

+673
-493
lines changed

crates/but-api/src/commands/workspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn ref_metadata_toml(project: &Project) -> anyhow::Result<VirtualBranchesTomlMet
2828
#[api_cmd]
2929
#[tauri::command(async)]
3030
#[instrument(err(Debug))]
31-
pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ui::ref_info::RefInfo, Error> {
31+
pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ui::RefInfo, Error> {
3232
let project = gitbutler_project::get(project_id)?;
3333
let ctx = CommandContext::open(&project, AppSettings::load_from_default_path_creating()?)?;
3434
let repo = ctx.gix_repo_for_merging_non_persisting()?;
@@ -42,7 +42,7 @@ pub fn head_info(project_id: ProjectId) -> Result<but_workspace::ui::ref_info::R
4242
},
4343
)
4444
.map_err(Into::into)
45-
.and_then(|info| but_workspace::ui::ref_info::RefInfo::for_ui(info, &repo).map_err(Into::into))
45+
.and_then(|info| but_workspace::ui::RefInfo::for_ui(info, &repo).map_err(Into::into))
4646
}
4747

4848
#[api_cmd]

crates/but-core/src/ref_metadata.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl Workspace {
8181
}
8282

8383
/// Metadata about branches, associated with any Git branch.
84-
#[derive(Clone, Eq, PartialEq, Default)]
84+
#[derive(serde::Serialize, Clone, Eq, PartialEq, Default)]
85+
#[serde(rename_all = "camelCase")]
8586
pub struct Branch {
8687
/// Standard data we want to know about any ref.
8788
pub ref_info: RefInfo,
@@ -132,7 +133,8 @@ impl<T: std::fmt::Debug> std::fmt::Debug for MaybeDebug<'_, T> {
132133
///
133134
/// It allows keeping track of when it changed, but also if we created it initially, a useful
134135
/// bit of information.
135-
#[derive(Default, Clone, Eq, PartialEq)]
136+
#[derive(serde::Serialize, Default, Clone, Eq, PartialEq)]
137+
#[serde(rename_all = "camelCase")]
136138
pub struct RefInfo {
137139
/// The time of creation, *if we created the reference*.
138140
pub created_at: Option<gix::date::Time>,
@@ -219,7 +221,8 @@ impl WorkspaceStack {
219221
}
220222

221223
/// Metadata about branches, associated with any Git branch.
222-
#[derive(Clone, Eq, PartialEq, Default)]
224+
#[derive(serde::Serialize, Clone, Eq, PartialEq, Default)]
225+
#[serde(rename_all = "camelCase")]
223226
pub struct Review {
224227
/// The number for the PR that was associated with this branch.
225228
pub pull_request: Option<usize>,

crates/but-workspace/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tempfile.workspace = true
3636

3737
[dev-dependencies]
3838
but-testsupport.workspace = true
39-
insta = "1.43.1"
39+
insta = { version = "1.43.1", features = ["json"] }
4040
but-core = { workspace = true, features = ["testing"] }
4141
# for stable hashes in `gitbuter-` crates while we use them.
4242
# TODO: remove once `gitbutler-repo` isn't needed anymore.

0 commit comments

Comments
 (0)