fix(windows): resolve the home directory via the standard lookup
Port of upstream grok-build 1.0.4/1.0.5. Two paths read $HOME only, which is usually unset on Windows outside Git Bash: - the global-gitignore fallback (prompt/ignore.rs) now uses std::env::home_dir(), the crate-wide idiom; - fast-worktree's resolve_kigi_home falls back to std::env::home_dir() with the same dunce canonicalization, eliminating the documented divergence from kigi_config::default_kigi_home. On Unix home_dir() reads $HOME first, so behavior is unchanged where HOME is set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KSy9S31pZNWXtRZNVJ1sDf
This commit is contained in:
1 parent
97de661554
commit
574122884a
2 files changed
+9
-7
No files matched your search
@@ -32,5 +32,5 @@ fn get_global_gitignore_path() -> Option<PathBuf> {
|
|||||||
git2::Config::open_default()
|
git2::Config::open_default()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|cfg| cfg.get_path("core.excludesFile").ok())
|
.and_then(|cfg| cfg.get_path("core.excludesFile").ok())
|
||||||
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".gitignore")))
|
.or_else(|| std::env::home_dir().map(|h| h.join(".gitignore")))
|
||||||
}
|
}
|
||||||
@@ -341,12 +341,14 @@ pub fn resolve_kigi_home() -> Result<PathBuf> {
|
|||||||
if let Ok(v) = std::env::var("KIGI_SHARE_DIR") {
|
if let Ok(v) = std::env::var("KIGI_SHARE_DIR") {
|
||||||
return Ok(PathBuf::from(v));
|
return Ok(PathBuf::from(v));
|
||||||
}
|
}
|
||||||
let home =
|
// Standard home-dir lookup (`USERPROFILE`/Known Folders on Windows, where
|
||||||
PathBuf::from(std::env::var("HOME").context("neither $KIGI_SHARE_DIR nor $HOME is set")?);
|
// `HOME` is usually unset outside Git Bash) — the same resolution as
|
||||||
// Canonicalize the home dir so worktree paths share the same physical .kigi
|
// kigi_config::default_kigi_home(), so worktree paths land in the same
|
||||||
// tree as trust/hooks even when it is symlinked. The dunce canonicalization
|
// physical .kigi tree as trust/hooks.
|
||||||
// must stay in sync with kigi_config::default_kigi_home();
|
let home = std::env::home_dir()
|
||||||
// home resolution deliberately differs ($HOME here vs std::env::home_dir()).
|
.context("neither $KIGI_SHARE_DIR nor a home directory could be resolved")?;
|
||||||
|
// Canonicalize so a symlinked home still maps to one physical tree; the
|
||||||
|
// dunce canonicalization must stay in sync with default_kigi_home().
|
||||||
Ok(dunce::canonicalize(&home).unwrap_or(home).join(".kigi"))
|
Ok(dunce::canonicalize(&home).unwrap_or(home).join(".kigi"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user