def get_repos(self, organization, team=None, f=None): ret = self.filter_repos(organization, team, f) for r in ret: t = Obj() t.name = None if not team and r.tid != 0: t = get_team(r.tid) elif team: t = team setattr(r, 'team', t) yield r
def render_rev(self, rev, organization, gist): rev['view'] = get_url(organization, gist, version=rev['sha']) rev['committer_time'] = format_time(rev['committer_time']) author = reqcache.get(rev['author_email']) if not author: author = get_user_from_alias(rev['author_email']) reqcache.set(rev['author_email'], author) if not author: author = Obj() author.email = rev['author_email'] author.name = None rev['author'] = author rev['diff'] = render_diff(rev['diff'])
def render_commit(commit, organization, repo): commit['author_date'] = datetime.fromtimestamp(float( commit['author_time'])).date() commit['author_time'] = format_time(commit['author_time']) author = reqcache.get(commit['author_email']) if not author: author = get_user_from_alias(commit['author_email']) reqcache.set(commit['author_email'], author) if not author: author = Obj() author.email = commit['author_email'] author.name = None author.avatar = lambda size: get_avatar(author.email, size) commit['author'] = author
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
def gen_tree(self, filenames, codes): for filename, content in zip(filenames, codes): d = Obj() d.name = filename d.content = lambda: content yield d