Skip to content

Commit 88b08b6

Browse files
authored
Merge pull request #11436 from Byron/fix
flyby fixes
2 parents 1a75f72 + 1d1f83a commit 88b08b6

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,19 @@ pub fn check_signing_settings(project_id: ProjectId) -> Result<bool> {
3636
project.check_signing_settings()
3737
}
3838

39+
/// NOTE: this function currently needs a tokio runtime to work.
3940
#[api_cmd_tauri]
4041
#[instrument(err(Debug))]
41-
pub fn git_clone_repository(repository_url: String, target_dir: PathBuf) -> Result<()> {
42-
let url_for_context = repository_url.clone();
43-
44-
std::thread::spawn(move || {
45-
tokio::runtime::Runtime::new()
46-
.unwrap()
47-
.block_on(gitbutler_git::clone(
48-
&repository_url,
49-
&target_dir,
50-
gitbutler_git::tokio::TokioExecutor,
51-
handle_git_prompt_clone,
52-
url_for_context,
53-
))
54-
})
55-
.join()
56-
.unwrap()
57-
.map_err(|e| anyhow::anyhow!("{e}"))
42+
pub async fn git_clone_repository(repository_url: String, target_dir: PathBuf) -> Result<()> {
43+
gitbutler_git::clone(
44+
&repository_url,
45+
&target_dir,
46+
gitbutler_git::tokio::TokioExecutor,
47+
handle_git_prompt_clone,
48+
repository_url.clone(),
49+
)
50+
.await?;
51+
Ok(())
5852
}
5953

6054
async fn handle_git_prompt_clone(prompt: String, url: String) -> Option<String> {

crates/but-claude/src/bridge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ async fn spawn_command(
427427
let mcp_config = serde_json::to_string(mcp_config)?;
428428
let mut command = Command::new(claude_executable);
429429

430-
/// Don't create a terminal window on windows.
430+
// Don't create a terminal window on windows.
431431
#[cfg(windows)]
432432
{
433433
use std::os::windows::process::CommandExt;
@@ -1039,7 +1039,7 @@ pub async fn check_claude_available(claude_executable: &str) -> ClaudeCheckResul
10391039
let mut command = Command::new(claude_executable);
10401040
command.arg("--version");
10411041

1042-
/// Don't create a terminal window on windows.
1042+
// Don't create a terminal window on windows.
10431043
#[cfg(windows)]
10441044
{
10451045
use std::os::windows::process::CommandExt;

crates/but-claude/src/compact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub async fn generate_summary(
234234

235235
let mut cmd = Command::new(claude_executable);
236236

237-
/// Don't create a terminal window on windows.
237+
// Don't create a terminal window on windows.
238238
#[cfg(windows)]
239239
{
240240
use std::os::windows::process::CommandExt;

crates/but-server/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ async fn handle_command(
340340
"git_get_local_config" => legacy::repo::git_get_local_config_cmd(request.params),
341341
"git_set_local_config" => legacy::repo::git_set_local_config_cmd(request.params),
342342
"check_signing_settings" => legacy::repo::check_signing_settings_cmd(request.params),
343-
"git_clone_repository" => legacy::repo::git_clone_repository_cmd(request.params),
343+
"git_clone_repository" => legacy::repo::git_clone_repository_cmd(request.params).await,
344344
"get_uncommited_files" => legacy::repo::get_uncommited_files_cmd(request.params),
345345
"get_commit_file" => legacy::repo::get_commit_file_cmd(request.params),
346346
"get_workspace_file" => legacy::repo::get_workspace_file_cmd(request.params),

crates/gitbutler-git/src/executor/tokio/windows.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, os::windows::io::AsRawHandle, path::Path, time::Duration};
1+
use std::{os::windows::io::AsRawHandle, path::Path, time::Duration};
22

33
use tokio::{
44
io::{AsyncBufReadExt, AsyncWriteExt, BufStream},
@@ -45,20 +45,20 @@ impl Socket for BufStream<NamedPipeServer> {
4545

4646
/// A server for the `askpass` protocol using Tokio.
4747
pub struct TokioAskpassServer {
48-
server: Mutex<RefCell<NamedPipeServer>>,
48+
server: Mutex<NamedPipeServer>,
4949
connection_string: String,
5050
}
5151

5252
impl TokioAskpassServer {
5353
pub(crate) fn new() -> Result<Self, std::io::Error> {
5454
let connection_string = format!("{ASKPASS_PIPE_PREFIX}{}", rand::random::<u64>());
5555

56-
let server = Mutex::new(RefCell::new(
56+
let server = Mutex::new(
5757
ServerOptions::new()
5858
.first_pipe_instance(true)
5959
.max_instances(2)
6060
.create(&connection_string)?,
61-
));
61+
);
6262

6363
Ok(TokioAskpassServer {
6464
server,
@@ -71,21 +71,22 @@ impl AskpassServer for TokioAskpassServer {
7171
type Error = std::io::Error;
7272
type SocketHandle = BufStream<NamedPipeServer>;
7373

74-
// We can ignore clippy here since we locked the mutex.
75-
#[expect(clippy::await_holding_refcell_ref)]
7674
async fn accept(&self, timeout: Option<Duration>) -> Result<Self::SocketHandle, Self::Error> {
77-
let server = self.server.lock().await;
75+
let mut server = self.server.lock().await;
7876

7977
if let Some(timeout) = timeout {
80-
tokio::time::timeout(timeout, server.borrow().connect()).await??;
78+
tokio::time::timeout(timeout, server.connect()).await??;
8179
} else {
82-
server.borrow().connect().await?;
80+
server.connect().await?;
8381
}
8482

8583
// Windows is weird. The server becomes the peer connection,
8684
// and before we use the new connection, we first create
8785
// a new server to listen for the next connection.
88-
let client = server.replace(ServerOptions::new().create(&self.connection_string)?);
86+
let client = std::mem::replace(
87+
&mut *server,
88+
ServerOptions::new().create(&self.connection_string)?,
89+
);
8990

9091
Ok(tokio::io::BufStream::new(client))
9192
}
@@ -101,7 +102,7 @@ impl core::fmt::Display for TokioAskpassServer {
101102
impl Drop for TokioAskpassServer {
102103
fn drop(&mut self) {
103104
// Best effort
104-
let _ = self.server.get_mut().get_mut().disconnect();
105+
let _ = self.server.get_mut().disconnect();
105106
}
106107
}
107108

crates/gitbutler-git/src/repository.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use std::{collections::HashMap, path::Path, time::Duration};
2-
31
use futures::{FutureExt, select};
42
use gix::{bstr::ByteSlice, config::tree::Key};
53
use rand::Rng;
4+
use std::{collections::HashMap, path::Path, time::Duration};
65

76
use super::executor::{AskpassServer, GitExecutor, Pid, Socket};
87
use crate::RefSpec;

0 commit comments

Comments
 (0)