本文整理汇总了Python中vilya.models.project.CodeDoubanProject.get_committers_by_project方法的典型用法代码示例。如果您正苦于以下问题:Python CodeDoubanProject.get_committers_by_project方法的具体用法?Python CodeDoubanProject.get_committers_by_project怎么用?Python CodeDoubanProject.get_committers_by_project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.project.CodeDoubanProject
的用法示例。
在下文中一共展示了CodeDoubanProject.get_committers_by_project方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_pull
# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import get_committers_by_project [as 别名]
def add_pull(ticket, pullreq, user):
from dispatches import dispatch
from vilya.libs.text import get_mentions_from_text
from vilya.libs.signals import pullrequest_signal
from vilya.models.user import get_author_by_email
from vilya.models.user import User
from vilya.models.trello.core import process_trello_notify
reporter = user.username
commits = pullreq.commits
# TODO: refactory is! auto number how to?
shas = [p.sha for p in commits]
ticket_len = Ticket.get_count_by_proj_id(ticket.project_id)
if ticket_len == 0:
# 检查是否创建过新PR,若未创建过则以旧PR号为基准累加
max_ticket_id = PullRequest.get_max_ticket_id(ticket.project_id)
if max_ticket_id >= 0:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author,
max_ticket_id + 1)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
pullreq = pullreq.insert(ticket.ticket_number)
if shas:
ticket.add_commits(','.join(shas), reporter)
noti_receivers = [committer.name
for committer in CodeDoubanProject.get_committers_by_project(pullreq.to_proj.id)] # noqa
noti_receivers = noti_receivers + [pullreq.to_proj.owner.name]
get_commit_author = lambda u: get_author_by_email(u.email.encode('utf-8'))
commit_authors = {get_commit_author(c.author) for c in commits}
commit_authors = {a for a in commit_authors if a}
noti_receivers.extend(commit_authors)
# diffs, author_by_file, authors = pullreq.get_diffs(with_blame=True)
# FIXME: diffs没用到?
# diffs = pullreq.get_diffs()
# blame代码变更的原作者, 也加到at users
at_users = get_mentions_from_text(ticket.description)
# at_users.extend(authors)
at_users.append(pullreq.to_proj.owner_id)
at_users = set(at_users)
# FIXME: invited_users is used on page /hub/my_pull_requests/
invited_users = [User(u).add_invited_pull_request(ticket.id)
for u in at_users]
ProjectOwnLRUCounter(user.username).use(pullreq.to_proj.id)
ProjectWatchLRUCounter(user.username).use(pullreq.to_proj.id)
# TODO: 重构Feed之后取消这个信号的发送
pullrequest_signal.send(user.username,
extra_receivers=noti_receivers,
pullreq=pullreq,
comment=ticket.description,
ticket_id=ticket.ticket_id,
ticket=ticket,
status="unmerge",
new_version=True)
dispatch('pullreq',
data=dict(sender=user.username,
content=ticket.description,
ticket=ticket,
status='unmerge',
new_version=True,
extra_receivers=noti_receivers))
dispatch('pr_actions',
data=dict(type='pr_opened',
hooks=pullreq.to_proj.hooks,
author=user,
title=ticket.title,
body=ticket.description,
ticket=ticket,
pullreq=pullreq))
# FIXME: move to dispatch
process_trello_notify(user, ticket)
return pullreq