code: def from_git(cls, sha="HEAD"):
      process = subprocess.Popen(
          [
              "git",
              "rev-list",
              "--format=NAME: %an%nEMAIL: %aE%nDATE: %at%nMESSAGE:%n%B",
              "--max-count=1",
              sha,
          ],
          stdout=subprocess.PIPE,
      )
      out, err = process.communicate()
  
      # If there is no Git repo, exit code will be non-zero
      if process.returncode == 0:
          lines = out.strip().decode().split(os.linesep)
  
          check, sha = lines[0].split("commit ")
          if check or not sha:
              logger.error("bad git parse: %s" % out)
  
          check, author_name = lines[1].split("NAME: ")
          if check or not author_name:
              logger.error("bad git parse for NAME: %s" % out)
  
          check, author_email = lines[2].split("EMAIL: ")
          if check or not author_email:
              logger.error("bad git parse for EMAIL: %s" % out)
  
          check, date = lines[3].split("DATE: ")
          if check or not date:
              logger.error("bad git parse for DATE: %s" % out)
          created_at = datetime.datetime.fromtimestamp(int(date))
  
          check, message = lines[4], os.linesep.join(lines[5:])
          if check != "MESSAGE:" or not message:
              logger.error("bad git parse for MESSAGE: %s" % out)
  
          return Commit.get_or_create(
              sha=sha,
              author_name=author_name,
              author_email=author_email,
              created_at=created_at,
              message=message,
          )
      else:
          return None
  
imports: import datetime
  import inflection
  import subprocess
  import logging
  import os
  from sqlalchemy import Column, Float, Integer, String, DateTime, JSON, func, ForeignKey, Index, UniqueConstraint
  from sqlalchemy.dialects.postgresql import JSONB
  from sqlalchemy.ext.declarative import declarative_base, declared_attr
  from sqlalchemy.orm import sessionmaker, relationship, scoped_session
  from sqlalchemy import TypeDecorator, types, desc
  from sqlalchemy.inspection import inspect
  import lore.io
  import json
label_desc: Use image node_id 1 for calling the Commit obj's underlying member method code with example usage: obj.from_git(cls, sha) and returns: Commit, None