code: def commit_hash(dir='.'):
      
  
      cmd = ['git', 'rev-parse', 'HEAD']
  
      try:
          with open(os.devnull, 'w') as devnull:
              revision_hash = subprocess.check_output(
                  cmd,
                  cwd=dir,
                  stderr=devnull
              )
          if sys.version_info.major > 2:
              revision_hash = revision_hash.decode('ascii')
  
          return revision_hash.strip()
  
      except subprocess.CalledProcessError:
          return None
docs: Return commit hash for HEAD of checked out branch of the
      specified directory.