code: def get_repo_from_git_ref(
      git_ref: Union[GitRef, GitRefDisabled]
  ) -> Optional["git.Repo"]:
      if git_ref == GitRef.DISABLED:
          return None
  
      initial_repo_path = git_ref.resolve_path()
      if initial_repo_path is None:
          return None
  
      try:
          from git.exc import (
              InvalidGitRepositoryError,
              NoSuchPathError,
          )
  
          try:
              return get_git_repo(repo_path=initial_repo_path)
          except (NoSuchPathError, InvalidGitRepositoryError):
              return None
      except ImportError:
          return None
  
file_path: neptune-client/src/neptune/internal/utils/git.py
imports: import logging
  import warnings
  from dataclasses import dataclass
  from datetime import datetime
  from typing import TYPE_CHECKING, List, Optional, Union
  from neptune.attributes.constants import DIFF_HEAD_INDEX_PATH, UPSTREAM_INDEX_DIFF
  from neptune.types import File
  from neptune.types.atoms.git_ref import GitRef, GitRefDisabled
label_desc: Use image node_id 2 for calling a global function with example usage: get_repo_from_git_ref(git_ref) and returns: None, None, get_git_repo, None, None