is_git_repository

Function is_git_repository 

Source
pub fn is_git_repository(path: &Path) -> bool
Expand description

Checks if a path contains a Git repository (regular or bare).

This function detects both types of Git repositories:

  • Regular repositories: Contain a .git subdirectory
  • Bare repositories: Contain a HEAD file in the root

§Arguments

  • path - The path to check for a Git repository

§Returns

  • true if the path is a valid Git repository (regular or bare)
  • false if neither repository marker exists

§Examples

use std::path::Path;
use agpm_cli::git::is_git_repository;

// Check a regular repository
let repo_path = Path::new("/path/to/repo");
if is_git_repository(repo_path) {
    println!("Found Git repository");
}

// Check a bare repository
let bare_path = Path::new("/path/to/repo.git");
if is_git_repository(bare_path) {
    println!("Found bare Git repository");
}

§Performance

This is a lightweight synchronous check that performs at most two filesystem operations to determine repository type.