pub fn is_git_installed() -> boolExpand description
Checks if Git is installed and accessible on the system.
This function verifies that the system’s git command is available in the PATH
and responds to version queries. It’s a prerequisite check for all Git operations
in AGPM.
§Return Value
trueif Git is installed and responding to--versioncommandsfalseif Git is not found, not in PATH, or not executable
§Implementation Details
The function uses get_git_command() to determine the appropriate Git command
for the current platform, then executes git --version to verify functionality.
§Platform Differences
- Windows: Checks for
git.exe,git.cmd, orgit.batin PATH - Unix-like: Checks for
gitcommand in PATH - All platforms: Respects PATH environment variable ordering
§Examples
use agpm_cli::git::is_git_installed;
if is_git_installed() {
println!("Git is available - proceeding with repository operations");
} else {
eprintln!("Error: Git is not installed or not in PATH");
std::process::exit(1);
}§Usage in AGPM
This function is typically called during:
- Application startup to validate prerequisites
- Before any Git operations to provide clear error messages
- In CI/CD pipelines to verify build environment
§Alternative
For error-based validation with detailed context, use ensure_git_available():
use agpm_cli::git::ensure_git_available;
ensure_git_available()?; // Throws AgpmError::GitNotFound if not available