expose cherry pick api

This commit is contained in:
Nikita Galaiko 2023-10-23 15:57:44 +02:00 committed by GitButler
parent 552fe0c5cd
commit 04007e5e87
2 changed files with 28 additions and 0 deletions

View File

@ -193,6 +193,7 @@ fn main() {
virtual_branches::commands::can_apply_remote_branch,
virtual_branches::commands::list_remote_commit_files,
virtual_branches::commands::reset_virtual_branch,
virtual_branches::commands::cherry_pick_onto_virtual_branch,
keys::commands::get_public_key,
github::commands::init_device_oauth,
github::commands::check_auth_status,

View File

@ -416,3 +416,30 @@ pub async fn reset_virtual_branch(
.await
.map_err(Into::into)
}
#[tauri::command(async)]
#[instrument(skip(handle))]
pub async fn cherry_pick_onto_virtual_branch(
handle: AppHandle,
project_id: &str,
branch_id: &str,
target_commit_oid: &str,
) -> Result<Option<git::Oid>, Error> {
let project_id = project_id.parse().map_err(|_| Error::UserError {
code: Code::Validation,
message: "Malformed project id".to_string(),
})?;
let branch_id = branch_id.parse().map_err(|_| Error::UserError {
code: Code::Validation,
message: "Malformed branch id".to_string(),
})?;
let target_commit_oid = target_commit_oid.parse().map_err(|_| Error::UserError {
code: Code::Validation,
message: "Malformed commit oid".to_string(),
})?;
handle
.state::<Controller>()
.cherry_pick(&project_id, &branch_id, target_commit_oid)
.await
.map_err(Into::into)
}