mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 00:48:35 +00:00
use gix_path::env::shell() to get the shell in git2-hooks (#2612)
Co-authored-by: Johannes Agricola <naseschwarz@users.noreply.github.com>
This commit is contained in:
parent
7f88934d05
commit
0e3767102a
3 changed files with 3 additions and 25 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1138,6 +1138,7 @@ version = "0.4.0"
|
|||
dependencies = [
|
||||
"git2",
|
||||
"git2-testing",
|
||||
"gix-path",
|
||||
"log",
|
||||
"pretty_assertions",
|
||||
"shellexpand",
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ keywords = ["git"]
|
|||
|
||||
[dependencies]
|
||||
git2 = ">=0.17"
|
||||
gix-path = "0.10"
|
||||
log = "0.4"
|
||||
shellexpand = "3.1"
|
||||
thiserror = "2.0"
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ impl HookPaths {
|
|||
}
|
||||
|
||||
fn sh_command() -> Command {
|
||||
let mut command = Command::new(sh_path());
|
||||
let mut command = Command::new(gix_path::env::shell());
|
||||
|
||||
if cfg!(windows) {
|
||||
// This call forces Command to handle the Path environment correctly on windows,
|
||||
|
|
@ -243,30 +243,6 @@ fn sh_command() -> Command {
|
|||
command
|
||||
}
|
||||
|
||||
/// Get the path to the sh executable.
|
||||
/// On Windows get the sh.exe bundled with Git for Windows
|
||||
pub fn sh_path() -> PathBuf {
|
||||
if cfg!(windows) {
|
||||
Command::new("where.exe")
|
||||
.arg("git")
|
||||
.output()
|
||||
.ok()
|
||||
.map(|out| {
|
||||
PathBuf::from(Into::<String>::into(
|
||||
String::from_utf8_lossy(&out.stdout),
|
||||
))
|
||||
})
|
||||
.as_deref()
|
||||
.and_then(Path::parent)
|
||||
.and_then(Path::parent)
|
||||
.map(|p| p.join("usr/bin/sh.exe"))
|
||||
.filter(|p| p.exists())
|
||||
.unwrap_or_else(|| "sh".into())
|
||||
} else {
|
||||
"sh".into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn is_executable(path: &Path) -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
|
|
|||
Loading…
Reference in a new issue