code: def get_git_info():
      git_info = {}
      try:
          r = subprocess.run(
              ["git", "rev-parse", "--is-inside-work-tree"],
              stdout=subprocess.PIPE,
              stderr=subprocess.STDOUT,
              check=True,
          )
      except (subprocess.CalledProcessError, FileNotFoundError):
          # not a git repo
          return git_info
      else:
          output = r.stdout.decode("utf-8").strip().lower()
          if output != "true":
              # malformed result
              return git_info
  
      cmds = {
          "branch": ("git", "rev-parse", "--abbrev-ref", "HEAD"),
          "remote_origin_url": (
              "git",
              "config",
              "--get",
              "remote.origin.url",
          ),
          "commit": (
              "git",
              "log",
              "--pretty=format:%h/%ad/%an",
              "--date=iso-strict",
              "-1",
          ),
      }
      results = {}
      for key, cmd in cmds.items():
          try:
              r = subprocess.run(
                  cmd,
                  stdout=subprocess.PIPE,
                  stderr=subprocess.STDOUT,
                  check=True,
              )
          except subprocess.CalledProcessError:
              continue
          else:
              output = r.stdout.decode("utf-8").strip()
              results[key] = output
  
      try:
          commit_hash, commit_timestamp, commit_author = results.get(
              "commit"
          ).split("/")
      except (ValueError, AttributeError):
          commit_hash = commit_timestamp = commit_author = None
  
      git_info.update(
          {
              "branch": results.get("branch"),
              "remote_origin_url": results.get("remote_origin_url"),
              "commit": {
                  "hash": commit_hash,
                  "timestamp": commit_timestamp,
                  "author": commit_author,
              },
          }
      )
  
      return git_info
  
imports: import logging
  import subprocess
label_desc: Use image node_id 3 for calling a global function with example usage: get_git_info() and returns: git_info, git_info, git_info