def run_git_command(repo_path: str, command: list[str]) -> tuple[bool, str]:
    """
    Run a git command in the specified repository.

    This function provides a safe way to execute git commands with:
    - Timeout protection (30 seconds) to prevent hanging
    - Proper error handling and output capture
    - Working directory context management

    Args:
        repo_path: Path to the git repository (working directory)
        command: Git command as a list of arguments (excluding 'git' itself)

    Returns:
        Tuple of (success, output/error)
        - success: True if command returned 0, False otherwise
        - output/error: stdout if successful, stderr or error message if failed
    """
    # Verify the repository path exists before trying to use it
    if not Path(repo_path).exists():
        return False, f"Repository path does not exist: {repo_path}"

    try:
        # Execute git command with safety measures
        result = subprocess.run(
            ["git"] + command,
            cwd=repo_path,  # Run in repository directory
            capture_output=True,  # Capture stdout and stderr
            text=True,  # Return strings instead of bytes
            timeout=30,  # Prevent hanging on slow operations
        )

        if result.returncode == 0:
            return True, result.stdout
        else:
            return False, result.stderr

    except subprocess.TimeoutExpired:
        return False, "Command timed out after 30 seconds"
    except FileNotFoundError as e:
        # This can happen if git is not installed or repo_path issues
        return False, f"Git command failed - path not found: {str(e)}"
    except Exception as e:
        return False, f"Git command failed: {str(e)}"

    Run a git command in the specified repository.

    This function provides a safe way to execute git commands with:
    - Timeout protection (30 seconds) to prevent hanging
    - Proper error handling and output capture
    - Working directory context management

    Args:
        repo_path: Path to the git repository (working directory)
        command: Git command as a list of arguments (excluding 'git' itself)

    Returns:
        Tuple of (success, output/error)
        - success: True if command returned 0, False otherwise
        - output/error: stdout if successful, stderr or error message if failed
    
utils/git_utils.py