本文整理汇总了Python中vilya.models.pull.PullRequest类的典型用法代码示例。如果您正苦于以下问题:Python PullRequest类的具体用法?Python PullRequest怎么用?Python PullRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PullRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _index
def _index(self, request):
user = self.user
yours = user.get_user_submit_pull_requests()
participated = user.get_participated_pull_requests()
invited = user.get_invited_pull_requests()
yours_list = [PullRequest.get_by_ticket(ticket).as_dict()
for ticket in yours]
participated_list = [PullRequest.get_by_ticket(ticket).as_dict()
for ticket in participated]
invited_list = [PullRequest.get_by_ticket(ticket).as_dict()
for ticket in invited]
yours_list = filter(lambda t: t, yours_list)
participated = filter(lambda t: t, participated)
invited_list = filter(lambda t: t, invited_list)
rs = []
if yours_list:
rs.append({'section': 'Yours', 'pulls': yours_list})
if participated_list:
rs.append({'section': 'Participated', 'pulls': participated_list})
if invited_list:
rs.append({'section': 'Invited', 'pulls': invited_list})
return rs
示例2: new
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())
示例3: create
def create(self, request):
user = request.user
if not user:
raise AccessError
from_proj = request.get_form_var('from_proj')
from_ref = request.get_form_var('from_ref')
to_ref = request.get_form_var('to_ref')
to_proj = request.get_form_var('to_proj')
title = request.get_form_var('title', '').decode('utf-8')
comment = request.get_form_var('body', '').decode('utf-8')
if not all([from_ref, from_proj, to_ref, to_proj]):
raise TraversalError
from_proj = CodeDoubanProject.get_by_name(from_proj)
to_proj = CodeDoubanProject.get_by_name(to_proj)
if from_proj != to_proj:
if not from_proj.has_push_perm(user.name):
raise AccessError(
"Need push permission to create PR on another project")
pullreq = PullRequest.open(from_proj, from_ref, to_proj, to_ref)
ticket = Ticket(None, None, to_proj.id, title, comment,
user.username, None, None)
pullreq = add_pull(ticket, pullreq, user)
ticket = pullreq.ticket
return request.redirect(str('/%s/pull/%s/' % (to_proj.name,
ticket.ticket_id)))
示例4: test_single_project
def test_single_project(self):
skip_test()
u_to = User("admin")
u_from = User("testuser")
to_proj = self._prj("test", "admin")
self._add(to_proj, u_to, "README.md", "hi")
from_proj = self._prj("testuser/test", "testuser", to_proj.id)
self._add(from_proj, u_from, "README.md", "hello")
pullreq = PullRequest.open(from_proj, "master", to_proj, "master")
ticket = Ticket(None, None, to_proj.id, "title", "desc", "testuser",
None, None)
pullreq = add_pull(ticket, pullreq, u_from)
iss = ProjectIssue.add(title='title1', description='desc1',
creator='owner', project=to_proj.id)
IssuePRSearch.index_a_project(to_proj)
res = IssueSearch.search_a_phrase('title1', to_proj.id)
res = SearchEngine.decode(res, ('issue_id',))
res = [id for id, in res]
assert len(res) == 1
assert res[0] == iss.id
res = PullRequestSearch.search_a_phrase('title', to_proj.id)
res = SearchEngine.decode(res, ('issue_id',))
res = [id for id, in res]
assert len(res) == 1
示例5: main
def main():
rs = store.execute("select id "
"from codedouban_ticket")
for r in rs:
id, = r
ticket = Ticket.get(id)
# update merge
pullreq = PullRequest.get_by_ticket(ticket)
author = pullreq.merge_by or pullreq.to_proj.owner_id
time = pullreq.merge_time
ticket_id = ticket.id
id = 0
if not get_node(author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time) and time:
print id, author, time, ticket_id
store.execute("insert into ticket_nodes "
"(author, type, type_id, ticket_id, created_at) "
"value (%s, %s, %s, %s, %s)",
(author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time))
store.commit()
# update close
author = ticket.close_by or ticket.author
time = ticket.closed
ticket_id = ticket.id
id = 0
if not get_node(author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time) and time:
print id, author, time, ticket_id
store.execute("insert into ticket_nodes "
"(author, type, type_id, ticket_id, created_at) "
"value (%s, %s, %s, %s, %s)",
(author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time))
store.commit()
print "update %s close & merge pulls" % len(rs)
示例6: test_get_commits
def test_get_commits(self):
"""应该能够得到所有将合并的改动"""
with setup2repos('prj3') as (path, repo, fork_path, fork_repo):
pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
commits = pullreq.commits
eq_(len(commits), 1)
示例7: get
def get(self, request):
_date_from = None
_date_to = None
state = request.get_form_var('state', '')
author = request.get_form_var('author', '')
date_from = request.get_form_var('from', '')
date_to = request.get_form_var('to', '')
if not state or state == "open":
closed = False
else:
closed = True
if date_from:
_date_from = date_from
if date_to:
_date_to = date_to
tickets = Ticket.gets(project_id=self.repo.id,
author=author,
date_from=_date_from,
date_to=_date_to,
closed=closed)
pulls = []
for t in tickets:
pull = PullRequest.get_by_proj_and_ticket(self.repo.id,
t.ticket_number)
pulls.append(pull.as_dict())
return pulls
示例8: __init__
def __init__(self, ticket):
self.project = CodeDoubanProject.get(ticket.project_id)
self.proj_name = self.project.name
self.ticket_id = ticket.ticket_number
self.ticket = ticket
self.pullreq = PullRequest.get_by_proj_and_ticket(
self.project.id, self.ticket_id)
示例9: add_code_review_action
def add_code_review_action(sender, **kw):
data = format_code_review_info(sender, **kw)
ticket = kw['ticket']
author = kw['author']
pullreq = PullRequest.get_by_ticket(ticket)
feeds = get_related_feeds(author, pullreq.to_proj)
for feed in feeds:
feed.add_action(data)
示例10: open_pulls
def open_pulls(self):
from vilya.models.ticket import Ticket
from vilya.models.pull import PullRequest
pulls = [PullRequest.get_by_proj_and_ticket(self.id,
t.ticket_id)
for t in Ticket.gets_by_proj(self.id,
limit=9999)]
return pulls
示例11: test_ticket_count
def test_ticket_count(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
pullreq = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq = pullreq.insert(p1_t2.ticket_number)
# test ticket count
assert int(Ticket.get_count_by_proj(self.proj1.id)) == 2
示例12: __init__
def __init__(self, data):
NotificationDispatcher.__init__(self, data)
self._sender = data.get('sender')
self._comment = data.get('comment')
self._content = self._comment.content if self._comment else data.get('content', '')
self._ticket = data.get('ticket')
self._pullreq = PullRequest.get_by_ticket(self._ticket)
self._target = self._pullreq.to_proj
self._is_ticketcomment = isinstance(self._comment, TicketComment)
示例13: test_is_auto_mergable_should_not_commit_merge
def test_is_auto_mergable_should_not_commit_merge(self):
"""调用 is_auto_mergable() 不应该导致仓库被 merge """
with setup2repos('prj1') as \
(path, repo, fork_path, fork_repo):
pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
ok_(pullreq.is_auto_mergable())
with self.clone_clean(path) as workdir:
assert not os.path.exists(join(workdir, 'a'))
示例14: clear_pull
def clear_pull(cls, name, pull_id):
project = cls.get_by_name(name)
if not project:
return None
from vilya.models.pull import PullRequest
pull = PullRequest.gets_by(to_project=project.id, ticket_id=pull_id,
force_flush=True)
if pull:
return True
return None
示例15: index_a_project_pr
def index_a_project_pr(cls, project):
rs = store.execute("select ticket_id from pullreq "
"where to_project=%s", project.id)
for r, in rs:
pr = PullRequest.get_by_proj_and_ticket(project.id, r)
if pr:
data = pr.as_dict()
if data:
serial = "%s_%s" % (project.index_name, r)
cls.index_an_object(serial, data)