fix sync sign utility

This commit is contained in:
Josh Junon 2024-05-08 12:16:06 +02:00
parent ca714084b1
commit 738e47a377
No known key found for this signature in database

View File

@ -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<P, Extra>(
pub fn sign_commit_sync(
repo_path: impl AsRef<Path>,
base_commitish: impl AsRef<str>,
branch_id: Option<BranchId>,
) -> Result<String, impl std::error::Error> {
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())
}