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)
| 1602 | /// location). Returns the resolved absolute path, or `None` if the key |
| 1603 | /// is absent from both files. |
| 1604 | fn 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 | /// |
no test coverage detected