当前位置: 首页>>代码示例>>Python>>正文


Python PullRequest.open方法代码示例

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


在下文中一共展示了PullRequest.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_single_project

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:27,代码来源:test_search.py

示例2: create

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:28,代码来源:pull.py

示例3: test_get_commits

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:9,代码来源:test_model.py

示例4: test_ticket_count

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:19,代码来源:test_ticket.py

示例5: test_is_auto_mergable_should_not_commit_merge

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:11,代码来源:test_model.py

示例6: new

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [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())
开发者ID:000fan000,项目名称:code,代码行数:58,代码来源:pull.py

示例7: test_is_up_to_date

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:13,代码来源:test_model.py

示例8: test_merge

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:14,代码来源:test_model.py

示例9: test_pr_stat

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    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,代码行数:41,代码来源:test_stat.py

示例10: test_ticket

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
 def test_ticket(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)
     assert p1_t1.ticket_id == 1
     assert p1_t1.title == title
     assert p1_t1.description == desc
     assert p1_t1.author == author
     p2_t1 = Ticket.add(self.proj2.id, title, desc, author)
     pullreq2 = PullRequest.open(
         self.proj2_fork, 'master', self.proj2, 'master')
     pullreq2 = pullreq2.insert(p2_t1.ticket_number)
     assert p2_t1.ticket_id == 1
     ticket = Ticket.get_by_projectid_and_ticketnumber(
         self.proj1.id, p1_t1.ticket_id)
     assert ticket.id == p1_t1.id
     ticket = Ticket.get_by_projectid_and_ticketnumber(
         self.proj2.id, p2_t1.ticket_id)
     assert ticket.id == p2_t1.id
开发者ID:leeccong,项目名称:code,代码行数:25,代码来源:test_ticket.py

示例11: test_get_diffs

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    def test_get_diffs(self):
        """应该能够得到所有将合并的diff"""
        with setup2repos('prj4') as (path, repo, fork_path, fork_repo):

            # make some change in origin repo, too
            with clone(path) as work_path:
                with chdir(work_path):
                    with open('b', 'w') as f:
                        f.write('b')

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            diffs = pullreq.get_diff()
            # should not contain file b in origin
            eq_(diffs.length, 1)
开发者ID:000fan000,项目名称:code,代码行数:16,代码来源:test_model.py

示例12: test_ticket_close

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    def test_ticket_close(self):
        # close ticket
        title = 'test title'
        desc = 'test desc'
        author = 'testuser'

        p2_t1 = Ticket.add(self.proj2.id, title, desc, author)
        pullreq2 = PullRequest.open(
            self.proj2_fork, 'master', self.proj2, 'master')
        pullreq2 = pullreq2.insert(p2_t1.ticket_number)

        assert p2_t1.closed is None
        p2_t1.close('testuser')
        assert Ticket.get(p2_t1.id).closed is not None
开发者ID:leeccong,项目名称:code,代码行数:16,代码来源:test_ticket.py

示例13: test_ticket_commit

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    def test_ticket_commit(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)

        # ticket commits
        commits_value = '454418c61cd7ef1a65818121746b45064a5af5d6,454418c61cd7ef1a65818121746b45064a5af574'  # noqa
        p1_t1.add_commits(commits_value, author)
        commits = p1_t1.get_commits()
        assert len(commits) == 1
        assert commits[0].commits == commits_value
开发者ID:leeccong,项目名称:code,代码行数:17,代码来源:test_ticket.py

示例14: test_pullrequest

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    def test_pullrequest(self):
        pullreq1 = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        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.insert(ticket2.ticket_number)

        opened_prs = self.proj1_fork.open_parent_pulls
        assert len(opened_prs) == 1

        opened_prs = self.proj2_fork.open_parent_pulls
        assert len(opened_prs) == 1

        ticket1.close('testuser')
        opened_prs = self.proj1_fork.open_parent_pulls
        assert len(opened_prs) == 0

        ticket2.close('testuser')
        opened_prs = self.proj2_fork.open_parent_pulls
        assert len(opened_prs) == 0
开发者ID:000fan000,项目名称:code,代码行数:26,代码来源:test_pullrequest.py

示例15: test_ticket_update_desc

# 需要导入模块: from vilya.models.pull import PullRequest [as 别名]
# 或者: from vilya.models.pull.PullRequest import open [as 别名]
    def test_ticket_update_desc(self):
        title = 'test title'
        desc = 'test desc'
        author = 'testuser'

        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)

        new_title = 'this is new title'
        new_desc = 'this is new desc!'
        p1_t2.update(new_title, new_desc)
        p1_t2 = Ticket.get(p1_t2.id)
        assert p1_t2.title == new_title
        assert p1_t2.description == new_desc
开发者ID:leeccong,项目名称:code,代码行数:18,代码来源:test_ticket.py


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