'returns a string containing git branch, commit id and commit date'

@staticmethod
def _git_repo_info(repo_path):

    result = None
    if os.path.exists(repo_path):
        if os.path.isfile(repo_path):
            try:
                gitdir = yaml.safe_load(open(repo_path)).get('gitdir')
                if os.path.isabs(gitdir):
                    repo_path = gitdir
                else:
                    repo_path = os.path.join(repo_path[:(-4)], gitdir)
            except (IOError, AttributeError):
                return ''
        f = open(os.path.join(repo_path, 'HEAD'))
        line = f.readline().rstrip('\n')
        if line.startswith('ref:'):
            branch_path = os.path.join(repo_path, line[5:])
        else:
            branch_path = None
        f.close()
        if (branch_path and os.path.exists(branch_path)):
            branch = '/'.join(line.split('/')[2:])
            f = open(branch_path)
            commit = f.readline()[:10]
            f.close()
        else:
            commit = line[:10]
            branch = 'detached    HEAD'
            branch_path = os.path.join(repo_path, 'HEAD')
        date = time.localtime(os.stat(branch_path).st_mtime)
        if (time.daylight == 0):
            offset = time.timezone
        else:
            offset = time.altzone
        result = '({0}    {1})    last    updated    {2}    (GMT    {3:+04d})'.format(branch, commit, time.strftime('%Y/%m/%d    %H:%M:%S', date), int((offset / (-36))))
    else:
        result = ''
    return result
