code: def to_git_info(
      git_ref: Union[GitRef, GitRefDisabled]
  ) -> Optional[GitInfo]:
      try:
          repo = get_repo_from_git_ref(git_ref)
          commit = repo.head.commit
  
          active_branch = ""
  
          try:
              active_branch = repo.active_branch.name
          except TypeError as e:
              if str(e.args[0]).startswith(
                  "HEAD is a detached symbolic reference as it points to"
              ):
                  active_branch = "Detached HEAD"
  
          remote_urls = [remote.url for remote in repo.remotes]
  
          return GitInfo(
              commit_id=commit.hexsha,
              message=commit.message,
              author_name=commit.author.name,
              author_email=commit.author.email,
              commit_date=commit.committed_datetime,
              dirty=repo.is_dirty(index=False, untracked_files=True),
              branch=active_branch,
              remotes=remote_urls,
          )
      except:  # noqa: E722
          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 3 for calling a global function with example usage: to_git_info(git_ref) and returns: GitInfo, None