code: def commit_for_dir(dir):
      """Returns a tuple of commit and workspace status.
  
      Raises NoCommit if a commit is not available.
      """
      dir = os.path.abspath(dir)
      for scheme in COMMIT_INFO_SCHEMES:
          commit = _apply_scheme(
              dir,
              _resolve_str(scheme.commit_cmd),
              scheme.commit_pattern,
              scheme.commit_ok_errors,
          )
          if commit is None:
              raise NoCommit(dir)
          status = _apply_scheme(
              dir,
              scheme.status_cmd,
              scheme.status_pattern,
              scheme.status_ok_errors,
          )
          return _format_commit(commit, scheme), _format_status(status)
      raise NoCommit(dir)
  
imports: import collections
  import logging
  import re
  import os
  import subprocess
  from guild import config
  from guild import file_util
  from guild import util
  from guild.file_util import FileSelectRule
label_desc: Use image node_id 1 for calling a global function with example usage: commit_for_dir(dir) and returns: _format_commit,  _format_status