Skip to content

Commit 3c16635

Browse files
committed
Re-add HexHash to Request struct for create_reference call (#12354)
This was changed by accident, and a way to prevent such mistakes in future would be to not add serde support to `gix` types.
1 parent 1bba3a6 commit 3c16635

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/but-api/src/legacy/stack.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use tracing::instrument;
1313
pub mod create_reference {
1414
use serde::{Deserialize, Serialize};
1515

16+
use crate::json::HexHash;
17+
1618
#[derive(Deserialize, Serialize, Debug)]
1719
#[serde(rename_all = "camelCase")]
1820
pub struct Request {
@@ -26,7 +28,7 @@ pub mod create_reference {
2628
#[serde(tag = "type", content = "subject", rename_all = "camelCase")]
2729
pub enum Anchor {
2830
AtCommit {
29-
commit_id: gix::ObjectId,
31+
commit_id: HexHash,
3032
position: but_workspace::branch::create_reference::Position,
3133
},
3234
AtReference {
@@ -51,7 +53,10 @@ pub fn create_reference(
5153
.map(|anchor| -> Result<_> {
5254
Ok(match anchor {
5355
create_reference::Anchor::AtCommit { commit_id, position } => {
54-
but_workspace::branch::create_reference::Anchor::AtCommit { commit_id, position }
56+
but_workspace::branch::create_reference::Anchor::AtCommit {
57+
commit_id: commit_id.into(),
58+
position,
59+
}
5560
}
5661
create_reference::Anchor::AtReference { short_name, position } => {
5762
but_workspace::branch::create_reference::Anchor::AtSegment {

crates/but/src/command/legacy/branch/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyhow::bail;
22
use branch::Subcommands;
3+
use but_api::json::HexHash;
34
use but_core::ref_metadata::StackId;
45
use colored::Colorize;
56

@@ -83,7 +84,7 @@ pub fn handle(cmd: Option<Subcommands>, ctx: &mut but_ctx::Context, out: &mut Ou
8384
match anchor_id {
8485
CliId::Commit { commit_id: oid, .. } => {
8586
Some(but_api::legacy::stack::create_reference::Anchor::AtCommit {
86-
commit_id: (*oid),
87+
commit_id: HexHash(*oid),
8788
position: but_workspace::branch::create_reference::Position::Above,
8889
})
8990
}

0 commit comments

Comments
 (0)