parameters: (directory, commit_filter, start_commit="HEAD")
return_statement: return VersionInfo(hash_, revision, int(commit_timestamp))
docstring: Fetch the Git hash (and Cr-Commit-Position if any) for a given directory.
  
    Args:
      directory: The directory containing the .git directory.
      commit_filter: A filter to supply to grep to filter commits
      start_commit: A commit identifier. The result of this function
        will be limited to only consider commits before the provided
        commit.
    Returns:
      A VersionInfo object. On error all values will be 0.
docstring_summary: Fetch the Git hash (and Cr-Commit-Position if any) for a given directory.
docstring_tokens: Fetch the Git hash ( and Cr - Commit - Position if any ) for a given directory .
function: def FetchGitRevision(directory, commit_filter, start_commit="HEAD"):
    """
    Fetch the Git hash (and Cr-Commit-Position if any) for a given directory.
  
    Args:
      directory: The directory containing the .git directory.
      commit_filter: A filter to supply to grep to filter commits
      start_commit: A commit identifier. The result of this function
        will be limited to only consider commits before the provided
        commit.
    Returns:
      A VersionInfo object. On error all values will be 0.
    """
    hash_ = ''
  
    git_args = ['log', '-1', '--format=%H %ct']
    if commit_filter is not None:
      git_args.append('--grep=' + commit_filter)
  
    git_args.append(start_commit)
  
    output = _RunGitCommand(directory, git_args)
    hash_, commit_timestamp = output.split()
    if not hash_:
      return VersionInfo('0', '0', 0)
  
    revision = hash_
    output = _RunGitCommand(directory, ['cat-file', 'commit', hash_])
    for line in reversed(output.splitlines()):
      if line.startswith('Cr-Commit-Position:'):
        pos = line.rsplit()[-1].strip()
        logging.debug("Found Cr-Commit-Position '%s'", pos)
        revision = "{}-{}".format(hash_, pos)
        break
    return VersionInfo(hash_, revision, int(commit_timestamp))
function_tokens: def FetchGitRevision ( directory , commit_filter , start_commit = "HEAD" ) : hash_ = '' git_args = [ 'log' , '-1' , '--format=%H %ct' ] if commit_filter is not None : git_args . append ( '--grep=' + commit_filter ) git_args . append ( start_commit ) output = _RunGitCommand ( directory , git_args ) hash_ , commit_timestamp = output . split ( ) if not hash_ : return VersionInfo ( '0' , '0' , 0 ) revision = hash_ output = _RunGitCommand ( directory , [ 'cat-file' , 'commit' , hash_ ] ) for line in reversed ( output . splitlines ( ) ) : if line . startswith ( 'Cr-Commit-Position:' ) : pos = line . rsplit ( ) [ - 1 ] . strip ( ) logging . debug ( "Found Cr-Commit-Position '%s'" , pos ) revision = "{}-{}" . format ( hash_ , pos ) break return VersionInfo ( hash_ , revision , int ( commit_timestamp ) )