示例#1
0
 def render_tree(self, jagare, repo, organization, tree, version, team):
     ret = []
     readme = None
     for d in tree:
         data = Obj()
         if d['type'] == 'tree':
             data.url = get_url(organization,
                                repo,
                                view='repos.view',
                                team=team,
                                version=version,
                                path=d['path'])
         elif d['type'] == 'blob':
             data.url = get_url(organization,
                                repo,
                                view='repos.blob',
                                team=team,
                                version=version,
                                path=d['path'])
             if d['name'].startswith('README.'):
                 readme, content_type, _ = format_content(jagare,
                                                          repo,
                                                          d['path'],
                                                          version=version)
                 if content_type != 'file':
                     readme = None
         elif d['type'] == 'submodule':
             data.url = get_submodule_url(d['submodule'], d['sha'])
             d['name'] = '%s@%s' % (d['name'], d['sha'][:10])
         data.name = d['name']
         data.sha = d['sha']
         data.type = d['type']
         data.ago = format_time(d['commit']['committer']['ts'])
         data.message = d['commit']['message'][:150]
         data.commit = d['commit']['sha']
         data.path = d['path']
         ret.append(data)
     return readme, ret