'Get the currently checked out git revision for a given repository,
record it in g.versions, and return the short version of the hash.'

def record_repo_version(self, repo_name, git_dir):

    try:
        subprocess.check_output
    except AttributeError:
        pass
    else:
        try:
            revision = subprocess.check_output(['git', '--git-dir', git_dir, 'rev-parse', 'HEAD'])
        except subprocess.CalledProcessError as e:
            self.log.warning('Unable    to    fetch    git    revision:    %r', e)
        else:
            self.versions[repo_name] = revision.rstrip()
            return revision[:7]
    return '(unknown)'
