code: def get_commit_if_possible(filename, save_git_info):
      """Try to retrieve VCS information for a given file.
  
      Currently only supports git using the gitpython package.
  
      Parameters
      ----------
      filename : str
  
      Returns
      -------
          path: str
              The base path of the repository
          commit: str
              The commit hash
          is_dirty: bool
              True if there are uncommitted changes in the repository
      """
      if save_git_info is False:
          return None, None, None
  
      try:
          from git import Repo, InvalidGitRepositoryError
      except ImportError as e:
          raise ValueError(
              "Cannot import git (pip install GitPython).\n"
              "Either GitPython or the git executable is missing.\n"
              "You can disable git with:\n"
              "    sacred.Experiment(..., save_git_info=False)"
          ) from e
  
      directory = os.path.dirname(filename)
      try:
          repo = Repo(directory, search_parent_directories=True)
      except InvalidGitRepositoryError:
          return None, None, None
      try:
          path = repo.remote().url
      except ValueError:
          path = "git:/" + repo.working_dir
      is_dirty = repo.is_dirty()
      commit = repo.head.commit.hexsha
      return path, commit, is_dirty
  
imports: import functools
  import hashlib
  import os.path
  import re
  import sys
  from pathlib import Path
  import pkg_resources
  import sacred.optional
  from sacred import SETTINGS
  from sacred.utils import iter_prefixes
label_desc: Use image node_id 3 for calling a global function with example usage: get_commit_if_possible(filename, save_git_info) and returns: path,  commit,  is_dirty, None,  None,  None, None,  None,  None