本文整理汇总了Python中models.Branch.get_branch_for_name方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.get_branch_for_name方法的具体用法?Python Branch.get_branch_for_name怎么用?Python Branch.get_branch_for_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Branch
的用法示例。
在下文中一共展示了Branch.get_branch_for_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UploadBundle
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import get_branch_for_name [as 别名]
def UploadBundle(self, rpc_controller, req, done):
"""
Receives an uploaded Git style bundle and queues it for processing.
"""
rsp = UploadBundleResponse()
# can't get here if there isn't a current user
current_user = users.get_current_user()
if not Account.get_account_for_user(current_user).cla_verified:
rsp.status_code = UploadBundleResponse.UNAUTHORIZED_USER
done(rsp)
return
# Validate that we have an Account for everyone in reviewers
invalid_reviewers = []
reviewers = Account.get_accounts_for_emails([x for x in req.reviewers])
for i in range(0, len(reviewers)):
if not reviewers[i]:
invalid_reviewers.append(req.reviewers[i])
# Validate all of the email addresses
invalid_cc = []
for e in req.cc:
if not forms.fields.email_re.search(e):
invalid_cc.append(e)
# Return failure if any of that was bad
if invalid_reviewers or invalid_cc:
rsp.status_code = UploadBundleResponse.UNKNOWN_EMAIL
for e in invalid_reviewers:
rsp.invalid_reviewers.append(e)
for e in invalid_cc:
rsp.invalid_cc.append(e)
done(rsp)
return
reviewers = [x.user for x in reviewers]
cc = [db.Email(x) for x in req.cc]
if not req.dest_project:
rsp.status_code = UploadBundleResponse.UNKNOWN_PROJECT
done(rsp)
return
proj = req.dest_project
if proj.endswith(".git"):
proj = proj[0 : len(proj) - 4]
proj = Project.get_project_for_name(proj)
if not proj:
rsp.status_code = UploadBundleResponse.UNKNOWN_PROJECT
done(rsp)
return
if not req.dest_branch:
rsp.status_code = UploadBundleResponse.UNKNOWN_BRANCH
done(rsp)
brch = Branch.get_branch_for_name(proj, req.dest_branch)
if not brch:
rsp.status_code = UploadBundleResponse.UNKNOWN_BRANCH
done(rsp)
return
replaces = list()
ids_to_check = list()
for p in req.replace:
id = int(p.change_id)
ids_to_check.append(id)
replaces.append('%d %s' % (id, p.object_id))
if ids_to_check:
for id, c in zip(ids_to_check, Change.get_by_id(ids_to_check)):
if not c:
rsp.status_code = UploadBundleResponse.UNKNOWN_CHANGE
done(rsp)
return
if c.closed:
rsp.status_code = UploadBundleResponse.CHANGE_CLOSED
done(rsp)
return
rb = git_models.ReceivedBundle(
dest_project = proj,
dest_branch = brch,
owner = current_user,
state = git_models.ReceivedBundle.STATE_UPLOADING,
reviewers = reviewers,
cc = cc,
contained_objects = list(req.contained_object),
replaces = replaces)
rb.put()
rsp.bundle_id = str(rb.key().id())
self._store_segment(req, rsp, rb, 1)
done(rsp)