MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / read_global_hooks_path

Function read_global_hooks_path

src/agents/mod.rs:1604–1621  ·  view source on GitHub ↗

Reads `core.hooksPath` from the global gitconfig files. Checks `~/.gitconfig` first, then `~/.config/git/config` (the XDG location). Returns the resolved absolute path, or `None` if the key is absent from both files.

(home: &Path)

Source from the content-addressed store, hash-verified

1602/// location). Returns the resolved absolute path, or `None` if the key
1603/// is absent from both files.
1604fn read_global_hooks_path(home: &Path) -> Option<PathBuf> {
1605 let candidates = [
1606 home.join(".gitconfig"),
1607 home.join(".config").join("git").join("config"),
1608 ];
1609 for path in &candidates {
1610 if let Some(value) = parse_gitconfig_value(path, "core", "hookspath") {
1611 let expanded = expand_tilde(&value, home);
1612 let p = PathBuf::from(&expanded);
1613 if p.is_absolute() {
1614 return Some(p);
1615 }
1616 // Relative paths in gitconfig are relative to the home dir.
1617 return Some(home.join(p));
1618 }
1619 }
1620 None
1621}
1622
1623/// Minimal gitconfig parser: finds the value of `key` under `[section]`.
1624///

Callers 1

Calls 2

parse_gitconfig_valueFunction · 0.85
expand_tildeFunction · 0.85

Tested by

no test coverage detected