From 738e47a37776c97192e4854a6ca534c6ea759020 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 8 May 2024 12:16:06 +0200 Subject: [PATCH] fix sync sign utility --- crates/gitbutler-core/src/askpass.rs | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/gitbutler-core/src/askpass.rs b/crates/gitbutler-core/src/askpass.rs index 5bf968f7a..b0a31a37e 100644 --- a/crates/gitbutler-core/src/askpass.rs +++ b/crates/gitbutler-core/src/askpass.rs @@ -100,21 +100,29 @@ async fn handle_git_prompt_commit_sign_sync( /// Utility to synchronously sign a commit. /// Uses the Tokio runner to run the async function, /// and the global askpass broker to handle any prompts. -pub fn sign_commit_sync( +pub fn sign_commit_sync( repo_path: impl AsRef, base_commitish: impl AsRef, branch_id: Option, ) -> Result { + let repo_path = repo_path.as_ref().to_path_buf(); + let base_commitish: &str = base_commitish.as_ref(); + let base_commitish = base_commitish.to_string(); + // Run as sync - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap() - .block_on(gitbutler_git::sign_commit( - repo_path, - gitbutler_git::tokio::TokioExecutor, - base_commitish.as_ref().to_string(), - handle_git_prompt_commit_sign_sync, - branch_id, - )) + let handle = std::thread::spawn(move || { + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() + .block_on(gitbutler_git::sign_commit( + &repo_path, + gitbutler_git::tokio::TokioExecutor, + base_commitish, + handle_git_prompt_commit_sign_sync, + branch_id, + )) + }); + + tokio::task::block_in_place(|| handle.join().unwrap()) }