Skip to content

Commit 0e8b4cc

Browse files
authored
Merge pull request #11440 from Byron/fix
flyby fixes
2 parents 88b08b6 + 2e6bbf1 commit 0e8b4cc

File tree

5 files changed

+2
-189
lines changed

5 files changed

+2
-189
lines changed

DEVELOPMENT.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,6 @@ This will make an asset similar to our nightly build.
321321

322322
Building on Windows is a bit of a tricky process. Here are some helpful tips.
323323

324-
#### Nightly Compiler
325-
326-
As a few crates require nightly features on Windows, a `rust-toolchain.toml` is provided
327-
to have rustup use the right compiler version.
328-
329-
If for some reason this cannot be used or doesn't kick-in, one can also set an override.
330-
331-
```shell
332-
rustup override add nightly-2024-07-01
333-
```
334-
335-
If a stable nightly isn't desired or necessary, the latest nightly compiler can also be used:
336-
337-
```shell
338-
rustup override add nightly
339-
```
340-
341324
#### File permissions
342325

343326
We use `pnpm`, which requires a relatively recent version of Node.js.

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ unsafe impl super::GitExecutor for TokioExecutor {
7575

7676
debug_log_sanitised_git_cmd(&mut cmd);
7777

78-
#[cfg(test)]
79-
{
80-
eprintln!(
81-
"\n\n GIT STDOUT:\n\n{}\n\nGIT STDERR:\n\n{}\n\nGIT EXIT CODE: {}\n",
82-
String::from_utf8_lossy(&output.stdout),
83-
String::from_utf8_lossy(&output.stderr),
84-
output.status.code().unwrap_or(127) as usize
85-
);
86-
}
87-
8878
if !output.status.success() {
8979
tracing::error!(
9080
?cmd,

crates/gitbutler-git/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ pub use self::executor::tokio;
2828
pub use self::{
2929
error::Error,
3030
refspec::{Error as RefSpecError, RefSpec},
31-
repository::{clone, fetch, push, sign_commit},
31+
repository::{clone, fetch, push},
3232
};

crates/gitbutler-git/src/repository.rs

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ where
8787
{
8888
let mut current_exe = std::env::current_exe().map_err(Error::<E>::NoSelfExe)?;
8989
current_exe = current_exe.canonicalize().unwrap_or(current_exe);
90-
tracing::trace!(?current_exe);
9190

9291
// TODO(qix-): Get parent PID of connecting processes to make sure they're us.
9392
//let our_pid = std::process::id();
@@ -461,125 +460,6 @@ where
461460
Err(base_error.into())
462461
}
463462

464-
/// Signs the given commit-ish in the repository at the given path.
465-
/// Returns the newly signed commit SHA.
466-
///
467-
/// Any prompts for the user are passed to the asynchronous callback `on_prompt`,
468-
/// which should return the user's response or `None` if the operation should be
469-
/// aborted, in which case an `Err` value is returned from this function.
470-
pub async fn sign_commit<P, E, F, Extra, Fut>(
471-
repo_path: P,
472-
executor: E,
473-
base_commitish: String,
474-
on_prompt: F,
475-
extra: Extra,
476-
) -> Result<String, crate::Error<Error<E>>>
477-
where
478-
P: AsRef<Path>,
479-
E: GitExecutor,
480-
F: FnMut(String, Extra) -> Fut,
481-
Fut: std::future::Future<Output = Option<String>>,
482-
Extra: Send + Clone,
483-
{
484-
let repo_path = repo_path.as_ref();
485-
486-
// First, create a worktree to perform the commit.
487-
let worktree_path = repo_path
488-
.join(".git")
489-
.join("gitbutler")
490-
.join(".wt")
491-
.join(uuid::Uuid::new_v4().to_string());
492-
let args = [
493-
"worktree",
494-
"add",
495-
"--detach",
496-
"--no-checkout",
497-
worktree_path.to_str().unwrap(),
498-
base_commitish.as_str(),
499-
];
500-
let (status, stdout, stderr) = executor
501-
.execute(&args, repo_path, None)
502-
.await
503-
.map_err(Error::<E>::Exec)?;
504-
if status != 0 {
505-
return Err(Error::<E>::Failed {
506-
status,
507-
args: args.into_iter().map(Into::into).collect(),
508-
stdout,
509-
stderr,
510-
})?;
511-
}
512-
513-
// Now, perform the commit.
514-
let args = [
515-
"commit",
516-
"--amend",
517-
"-S",
518-
"-o",
519-
"--no-edit",
520-
"--no-verify",
521-
"--no-post-rewrite",
522-
"--allow-empty",
523-
"--allow-empty-message",
524-
];
525-
let (status, stdout, stderr) = execute_with_auth_harness(
526-
HarnessEnv::Repo(&worktree_path),
527-
&executor,
528-
&args,
529-
None,
530-
on_prompt,
531-
extra,
532-
)
533-
.await?;
534-
if status != 0 {
535-
return Err(Error::<E>::Failed {
536-
status,
537-
args: args.into_iter().map(Into::into).collect(),
538-
stdout,
539-
stderr,
540-
})?;
541-
}
542-
543-
// Get the commit hash that was generated
544-
let args = ["rev-parse", "--verify", "HEAD"];
545-
let (status, stdout, stderr) = executor
546-
.execute(&args, &worktree_path, None)
547-
.await
548-
.map_err(Error::<E>::Exec)?;
549-
if status != 0 {
550-
return Err(Error::<E>::Failed {
551-
status,
552-
args: args.into_iter().map(Into::into).collect(),
553-
stdout,
554-
stderr,
555-
})?;
556-
}
557-
558-
let commit_hash = stdout.trim().to_string();
559-
560-
// Finally, remove the worktree
561-
let args = [
562-
"worktree",
563-
"remove",
564-
"--force",
565-
worktree_path.to_str().unwrap(),
566-
];
567-
let (status, stdout, stderr) = executor
568-
.execute(&args, repo_path, None)
569-
.await
570-
.map_err(Error::<E>::Exec)?;
571-
if status != 0 {
572-
return Err(Error::<E>::Failed {
573-
status,
574-
args: args.into_iter().map(Into::into).collect(),
575-
stdout,
576-
stderr,
577-
})?;
578-
}
579-
580-
Ok(commit_hash)
581-
}
582-
583463
fn get_core_sshcommand<P>(harness_env: &HarnessEnv<P>) -> anyhow::Result<Option<String>>
584464
where
585465
P: AsRef<Path>,

crates/gitbutler-repo-actions/src/askpass.rs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, path::Path, sync::Arc};
1+
use std::{collections::HashMap, sync::Arc};
22

33
use gitbutler_stack::StackId;
44
use serde::Serialize;
@@ -93,43 +93,3 @@ impl AskpassBroker {
9393
}
9494
}
9595
}
96-
97-
async fn handle_git_prompt_commit_sign_sync(
98-
prompt: String,
99-
branch_id: Option<StackId>,
100-
) -> Option<String> {
101-
tracing::info!("received prompt for synchronous signed commit {branch_id:?}: {prompt:?}");
102-
get_broker()
103-
.submit_prompt(prompt, Context::SignedCommit { branch_id })
104-
.await
105-
}
106-
107-
/// Utility to synchronously sign a commit.
108-
/// Uses the Tokio runner to run the async function,
109-
/// and the global askpass broker to handle any prompts.
110-
pub fn sign_commit_sync(
111-
repo_path: impl AsRef<Path>,
112-
base_commitish: impl AsRef<str>,
113-
branch_id: Option<StackId>,
114-
) -> Result<String, impl std::error::Error> {
115-
let repo_path = repo_path.as_ref().to_path_buf();
116-
let base_commitish: &str = base_commitish.as_ref();
117-
let base_commitish = base_commitish.to_string();
118-
119-
// Run as sync
120-
let handle = std::thread::spawn(move || {
121-
tokio::runtime::Builder::new_multi_thread()
122-
.enable_all()
123-
.build()
124-
.unwrap()
125-
.block_on(gitbutler_git::sign_commit(
126-
&repo_path,
127-
gitbutler_git::tokio::TokioExecutor,
128-
base_commitish,
129-
handle_git_prompt_commit_sign_sync,
130-
branch_id,
131-
))
132-
});
133-
134-
tokio::task::block_in_place(|| handle.join().unwrap())
135-
}

0 commit comments

Comments
 (0)