本文整理汇总了Python中vilya.models.pull.PullRequest.get_by_from_and_to方法的典型用法代码示例。如果您正苦于以下问题:Python PullRequest.get_by_from_and_to方法的具体用法?Python PullRequest.get_by_from_and_to怎么用?Python PullRequest.get_by_from_and_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.pull.PullRequest
的用法示例。
在下文中一共展示了PullRequest.get_by_from_and_to方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import get_by_from_and_to [as 别名]
def new(self, request):
user = request.user
if not user:
raise AccessError
from_proj = self.project
from_ref = request.get_form_var('head_ref', from_proj.default_branch)
parent_proj = from_proj.get_forked_from()
to_proj = request.get_form_var('base_repo')
if to_proj:
to_proj = CodeDoubanProject.get_by_name(to_proj)
elif parent_proj:
to_proj = parent_proj
else:
to_proj = from_proj
if not to_proj:
raise TraversalError("The PR's upstream project is not existed")
to_ref = request.get_form_var('base_ref', to_proj.default_branch)
if from_proj != to_proj:
# Allow to create PR to a different project only if user has push perm
# ~~A bit weird, maybe should be separate perms
# ~~If from and to projects are the same, we should be in online edit mode
if not from_proj.has_push_perm(user.name):
raise AccessError(
"Need push permission to add a PR on another project")
pullreq = PullRequest.open(from_proj, from_ref, to_proj, to_ref)
family = from_proj.get_fork_network()
from_branches = from_proj.repo.branches
to_branches = to_proj.repo.branches
from_commit = pullreq.from_commit
to_commit = pullreq.to_commit
if not pullreq.can_pull:
raise TraversalError(
"The PR's head_ref or base_ref is not existed")
highlighted_projects = filter(None, [from_proj, parent_proj])
commits = pullreq.commits
n_commits = len(commits)
n_authors = len(set(c.author.username for c in commits))
ticket_title, ticket_desc = self._choose_default_PR_title_and_description(commits) # noqa
# get diff
diff = pullreq.get_diff(rename_detection=True)
n_files = diff.length
grouped_commits = groupby(commits, lambda c: c.author_time.date())
prs = PullRequest.get_by_from_and_to(
from_proj.id, from_ref, to_proj.id, to_ref)
open_pullreqs = []
for pr in prs:
t = Ticket.get_by_projectid_and_ticketnumber(
to_proj.id, pr.ticket_id)
if t and t.closed is None:
open_pullreqs.append(pr)
guideline_url = get_project_guidelines(to_proj)
teams = Team.get_all_team_uids()
return st('/pull/new.html', **locals())