• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pull.PullRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vilya.models.pull.PullRequest的典型用法代码示例。如果您正苦于以下问题:Python PullRequest类的具体用法?Python PullRequest怎么用?Python PullRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PullRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:000fan000,项目名称:code,代码行数:26,代码来源:pulls.py


示例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())
开发者ID:000fan000,项目名称:code,代码行数:56,代码来源:pull.py


示例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)))
开发者ID:000fan000,项目名称:code,代码行数:26,代码来源:pull.py


示例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
开发者ID:leeccong,项目名称:code,代码行数:25,代码来源:test_search.py


示例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)
开发者ID:000fan000,项目名称:code,代码行数:32,代码来源:update_ticket.py


示例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)
开发者ID:000fan000,项目名称:code,代码行数:7,代码来源:test_model.py


示例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
开发者ID:000fan000,项目名称:code,代码行数:27,代码来源:pulls.py


示例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)
开发者ID:000fan000,项目名称:code,代码行数:7,代码来源:pull.py


示例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)
开发者ID:leeccong,项目名称:code,代码行数:8,代码来源:feed.py


示例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
开发者ID:000fan000,项目名称:code,代码行数:8,代码来源:project.py


示例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
开发者ID:leeccong,项目名称:code,代码行数:17,代码来源:test_ticket.py


示例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)
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:codereview.py


示例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'))
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:test_model.py


示例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
开发者ID:000fan000,项目名称:code,代码行数:10,代码来源:project.py


示例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)
开发者ID:000fan000,项目名称:code,代码行数:10,代码来源:issue_pr_search.py


示例16: test_is_up_to_date

    def test_is_up_to_date(self):
        """应该能探测是否是已经merge过的"""
        with setup2repos('prj_uptodate') as (path, repo, fork_path, fork_repo):

            with self.clone_clean(path) as work_path:
                with chdir(work_path):
                    gyt.call(['git', 'pull', fork_path])
                    gyt.call(['git', 'push', 'origin', 'master'])

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            ok_(pullreq.is_up_to_date())
开发者ID:000fan000,项目名称:code,代码行数:11,代码来源:test_model.py


示例17: commits

    def commits(self, request):
        if not self.ticket:
            raise TraversalError()

        pr = PullRequest.get_by_proj_and_ticket(
            self.project.id, self.ticket.ticket_number)
        commits = pr.get_commits_shas()
        commits = [TicketCommits.commit_as_dict(self.project, c)
                   for c in commits]
        # commits = reduce(lambda x, y: x + y, commits)
        return commits
开发者ID:000fan000,项目名称:code,代码行数:11,代码来源:pulls.py


示例18: __init__

    def __init__(self, project_id, ticket_id):
        self.project_id = project_id
        self.ticket_id = ticket_id

        self.ticket = Ticket.get_by_projectid_and_ticketnumber(self.project_id,
                                                               self.ticket_id)

        if not self.ticket:
            raise NotFoundError('pull')

        self.pullreq = PullRequest.get_by_proj_and_ticket(
            self.project_id, self.ticket.ticket_number)
开发者ID:000fan000,项目名称:code,代码行数:12,代码来源:pulls.py


示例19: test_merge

    def test_merge(self):
        """merge()应该将远程代码合并到bare仓库中"""

        with setup2repos('prj_merge') as (path, repo, fork_path, fork_repo):

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            u = User('testmerge')
            pullreq.merge(u)

            with self.clone_clean(path) as work_path:
                content = open(join(work_path, 'a')).read()
                eq_(content, "a_hunk = [('idem', u'/* highlight style */'), ('rem', u'.highlight { color: #008000; font-weight: bold; } /* Keyword */'), ('add', u'.highlight .hll { background-color: #ffffcc; }'), ('add', u'.highlight  { backggggground: #ffffff; }'), ('add', u'.high .c { color: #808080; } /* Coomment */'), ('add', u'.highlight .err { color: #F00000; background-color: #F00A0A0; } /* Error */'), ('add', u'.highlight .k { color: #008000; font-weight: bold; } /* Keyword */'), ('idem', u'.highlight .o { color: #303; } /* Operator ****/'), ('idem', u'.highlight .cm { color: #808080; } /* Comment.Multiline */'),('idem', u'adfadsfadsf'),  ('idem', u'.highlight .cp { color: #507090; } /* Comment.Preproc */')]\n")  # noqa
开发者ID:000fan000,项目名称:code,代码行数:12,代码来源:test_model.py


示例20: test_pr_stat

    def test_pr_stat(self):
        TestCase.setUp(self)
        _, self.proj1, _, self.proj1_fork = setup_repos(
            mkdtemp(), 'testproject1')
        _, self.proj2, _, self.proj2_fork = setup_repos(
            mkdtemp(), 'testproject2')
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 0
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 0
        assert len(pr_rs) - pr_open_count == 0

        pullreq1 = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        pullreq1 = pullreq1.insert(ticket1.ticket_number)
        pullreq2 = PullRequest.open(
            self.proj2_fork, 'master', self.proj2, 'master')
        ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
        pullreq2 = pullreq2.insert(ticket2.ticket_number)
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 2
        assert len(pr_rs) - pr_open_count == 0

        ticket1.close("testuser")
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 1
        assert len(pr_rs) - pr_open_count == 1

        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 0
        ticket2.add_comment("comment1", "testuse1")
        ticket2.add_comment("comment2", "testuse2")
        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 2
开发者ID:000fan000,项目名称:code,代码行数:39,代码来源:test_stat.py



注:本文中的vilya.models.pull.PullRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sphinx_docs.SphinxDocs类代码示例发布时间:2022-05-26
下一篇:
Python project_issue.ProjectIssue类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap