Merge pull request #25 from springmaple/riir
Fix git-bash finding in Windows not working properly
This commit is contained in:
commit
e10bdac351
5 changed files with 34 additions and 9 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -172,6 +172,7 @@ dependencies = [
|
||||||
"normpath",
|
"normpath",
|
||||||
"palette",
|
"palette",
|
||||||
"regex",
|
"regex",
|
||||||
|
"same-file",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_path_to_error",
|
"serde_path_to_error",
|
||||||
|
@ -448,6 +449,15 @@ version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.203"
|
version = "1.0.203"
|
||||||
|
@ -770,6 +780,15 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
|
|
@ -23,6 +23,7 @@ indexmap = { version = "2.2.6", default-features = false }
|
||||||
normpath = { version = "1.2.0", default-features = false }
|
normpath = { version = "1.2.0", default-features = false }
|
||||||
palette = { version = "0.7.6", default-features = false }
|
palette = { version = "0.7.6", default-features = false }
|
||||||
regex = { version = "1.10.5", default-features = false }
|
regex = { version = "1.10.5", default-features = false }
|
||||||
|
same-file = { version = "1.0.6", default-features = false }
|
||||||
serde = { version = "1.0.203", default-features = false }
|
serde = { version = "1.0.203", default-features = false }
|
||||||
serde_json = { version = "1.0.118", default-features = false }
|
serde_json = { version = "1.0.118", default-features = false }
|
||||||
serde_path_to_error = { version = "0.1.16", default-features = false }
|
serde_path_to_error = { version = "0.1.16", default-features = false }
|
||||||
|
|
|
@ -18,6 +18,7 @@ deranged = { workspace = true, features = ["serde", "std"] }
|
||||||
directories = { workspace = true, features = [] }
|
directories = { workspace = true, features = [] }
|
||||||
indexmap = { workspace = true, features = ["serde", "std"] }
|
indexmap = { workspace = true, features = ["serde", "std"] }
|
||||||
palette = { workspace = true, features = ["std"] }
|
palette = { workspace = true, features = ["std"] }
|
||||||
|
same-file = { workspace = true, features = [] }
|
||||||
serde = { workspace = true, features = ["derive", "std"] }
|
serde = { workspace = true, features = ["derive", "std"] }
|
||||||
serde_json = { workspace = true, features = ["std"] }
|
serde_json = { workspace = true, features = ["std"] }
|
||||||
serde_path_to_error = { workspace = true, features = [] }
|
serde_path_to_error = { workspace = true, features = [] }
|
||||||
|
|
|
@ -41,7 +41,7 @@ _/\_\_ _/_/\_
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if let Err(err) = enable_ansi_support::enable_ansi_support() {
|
if let Err(err) = enable_ansi_support::enable_ansi_support() {
|
||||||
debug!(err, "could not enable ANSI escape code support");
|
debug!(%err, "could not enable ANSI escape code support");
|
||||||
}
|
}
|
||||||
|
|
||||||
let options = options().run();
|
let options = options().run();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::io::Write;
|
use std::io::{ErrorKind, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
@ -11,6 +11,7 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use normpath::PathExt as _;
|
use normpath::PathExt as _;
|
||||||
|
use same_file::is_same_file;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
@ -317,7 +318,7 @@ pub fn neofetch_path() -> Result<Option<PathBuf>> {
|
||||||
let neowofetch_path = if neowofetch_path.is_some() {
|
let neowofetch_path = if neowofetch_path.is_some() {
|
||||||
neowofetch_path
|
neowofetch_path
|
||||||
} else {
|
} else {
|
||||||
let current_exe_path = env::current_exe()
|
let current_exe_path: PathBuf = env::current_exe()
|
||||||
.and_then(|p| {
|
.and_then(|p| {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
|
@ -358,10 +359,13 @@ pub fn ensure_git_bash() -> Result<PathBuf> {
|
||||||
// See https://github.com/hykilpikonna/hyfetch/issues/233
|
// See https://github.com/hykilpikonna/hyfetch/issues/233
|
||||||
let windir = env::var_os("windir")
|
let windir = env::var_os("windir")
|
||||||
.context("`windir` environment variable is not set or invalid")?;
|
.context("`windir` environment variable is not set or invalid")?;
|
||||||
if bash_path == Path::new(&windir).join(r"System32\bash.exe") {
|
match is_same_file(&bash_path, Path::new(&windir).join(r"System32\bash.exe")) {
|
||||||
None
|
Ok(true) => None,
|
||||||
} else {
|
Ok(false) => Some(bash_path),
|
||||||
Some(bash_path)
|
Err(err) if err.kind() == ErrorKind::NotFound => Some(bash_path),
|
||||||
|
Err(err) => {
|
||||||
|
return Err(err).context("failed to check if paths refer to the same file");
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => bash_path,
|
_ => bash_path,
|
||||||
|
@ -417,7 +421,7 @@ pub fn ensure_git_bash() -> Result<PathBuf> {
|
||||||
let git_bash_path = if git_bash_path.is_some() {
|
let git_bash_path = if git_bash_path.is_some() {
|
||||||
git_bash_path
|
git_bash_path
|
||||||
} else {
|
} else {
|
||||||
let current_exe_path = env::current_exe()
|
let current_exe_path: PathBuf = env::current_exe()
|
||||||
.and_then(|p| p.normalize().map(|p| p.into()))
|
.and_then(|p| p.normalize().map(|p| p.into()))
|
||||||
.context("failed to get path of current running executable")?;
|
.context("failed to get path of current running executable")?;
|
||||||
let bash_path = current_exe_path
|
let bash_path = current_exe_path
|
||||||
|
@ -738,7 +742,7 @@ fn fastfetch_path() -> Result<Option<PathBuf>> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fall back to `fastfetch` in directory of current executable
|
// Fall back to `fastfetch` in directory of current executable
|
||||||
let current_exe_path = env::current_exe()
|
let current_exe_path: PathBuf = env::current_exe()
|
||||||
.and_then(|p| {
|
.and_then(|p| {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue