def get_commit_user(self, meta): user = Obj() commit = Obj() user.name = meta['committer']['name'] user.email = meta['committer']['email'] user.avatar = None commit.message = meta['message'] commit.user = user commit.sha = meta['sha'] commit.date = meta['committer']['date'] alias = get_alias_by_email(user.email) if alias: user = get_user(alias.uid) commit.user.name = user.name commit.user.avatar = user.avatar(18) return commit
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
def get_tree_with_content(jagare, tree, repo, organization, render=True, version='master'): ret = [] for d in tree: data = Obj() if d['type'] == 'blob': data.content, data.content_type, data.length = format_content( jagare, repo, d['path'], render=render, version=version, \ ) else: continue 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 ret