Skip to content

Commit 0be7457

Browse files
committed
fix: use bash -c to get interpretation of tilde and env vars in path
1 parent 7661b27 commit 0be7457

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

crates/gitbutler-repo/src/repository_ext.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,9 @@ impl RepositoryExt for git2::Repository {
401401
gpg_program = "ssh-keygen".to_string();
402402
}
403403

404-
let mut cmd = std::process::Command::new(gpg_program);
405-
cmd.args(["-Y", "sign", "-n", "git", "-f"]);
404+
let mut cmd = std::process::Command::new("bash");
405+
cmd.arg("-c");
406+
let gpg_cmd = format!("{} -Y sign -n git -f", gpg_program);
406407

407408
#[cfg(windows)]
408409
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
@@ -425,18 +426,26 @@ impl RepositoryExt for git2::Repository {
425426

426427
let key_file_path = key_storage.into_temp_path();
427428

428-
cmd.arg(&key_file_path);
429-
cmd.arg("-U");
430-
cmd.arg(&buffer_file_to_sign_path);
429+
cmd.arg(format!(
430+
"{} {} {} {}",
431+
gpg_cmd,
432+
&key_file_path.to_str().unwrap(),
433+
"-U",
434+
buffer_file_to_sign_path.to_str().unwrap()
435+
));
431436
cmd.stderr(Stdio::piped());
432437
cmd.stdout(Stdio::piped());
433438
cmd.stdin(Stdio::null());
434439

435440
let child = cmd.spawn()?;
436441
output = child.wait_with_output()?;
437442
} else {
438-
cmd.arg(signing_key);
439-
cmd.arg(&buffer_file_to_sign_path);
443+
cmd.arg(format!(
444+
"{} {} {}",
445+
gpg_cmd,
446+
signing_key,
447+
buffer_file_to_sign_path.to_str().unwrap()
448+
));
440449
cmd.stderr(Stdio::piped());
441450
cmd.stdout(Stdio::piped());
442451
cmd.stdin(Stdio::null());

0 commit comments

Comments
 (0)