Esempio n. 1
0
 def setUp(self):
     TestCase.setUp(self)
     for name in ('testproject1', 'testproject2', 'testproject1_fork',
                  'testproject2_fork'):
         delete_project(name)
     _, self.proj1, _, self.proj1_fork = setup_repos(mkdtemp(),
                                                     'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(mkdtemp(),
                                                     'testproject2')
Esempio n. 2
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(['git', 'init'])
        open('test', 'w').close()
        check_call(['git', 'add', 'test'])
        check_call(['git', 'commit', '-m', 'test'], env=env)

        branches = M.get_branches()
    eq_(branches, ['master'])
Esempio n. 3
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(['git', 'init'])
        open('test', 'w').close()
        check_call(['git', 'add', 'test'])
        check_call(['git', 'commit', '-m', 'test'], env=env)

        branches = M.get_branches()
    eq_(branches, ['master'])
Esempio n. 4
0
def test_get_branches_should_return_a_list_of_branch_names():
    with mkdtemp(cd=True):
        check_call(["git", "init"])
        open("test", "w").close()
        check_call(["git", "add", "test"])
        check_call(["git", "commit", "-m", "test"], env=env)

        branches = M.get_branches()
    eq_(branches, ["master"])
Esempio n. 5
0
    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
Esempio n. 6
0
    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
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo("test", bare=False)
     self._commit(repo, "test/file1", "content1", "msg1")
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file(
         "test/file1", "content1 modified", "change1", self.u, orig_hash=hash("content1"), branch=tmp_branch
     )
     with mkdtemp() as tmpdir:
         gyt.call(["git", "clone", repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
         repo_check.call("checkout master")
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
         repo_check.call("checkout %s" % tmp_branch)
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1 modified"
         repo_check.call("checkout master")
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
Esempio n. 8
0
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo('test', bare=False)
     self._commit(repo, 'test/file1', 'content1', 'msg1')
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file('test/file1', 'content1 modified', 'change1',
                          self.u, orig_hash=hash('content1'),
                          branch=tmp_branch)
     with mkdtemp() as tmpdir:
         gyt.call(['git', 'clone', repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout %s' % tmp_branch)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1 modified'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
Esempio n. 9
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
Esempio n. 10
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
Esempio n. 11
0
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo('test', bare=False)
     self._commit(repo, 'test/file1', 'content1', 'msg1')
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file('test/file1',
                          'content1 modified',
                          'change1',
                          self.u,
                          orig_hash=hash('content1'),
                          branch=tmp_branch)
     with mkdtemp() as tmpdir:
         gyt.call(['git', 'clone', repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout %s' % tmp_branch)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1 modified'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
Esempio n. 12
0
 def clone_clean(self, git_dir):
     with mkdtemp() as work_path:
         gyt.call(['git', 'clone', git_dir, work_path])
         assert os.path.exists(join(work_path, '.git'))
         yield work_path
Esempio n. 13
0
 def clone_clean(self, git_dir):
     with mkdtemp() as work_path:
         gyt.call(['git', 'clone', git_dir, work_path])
         assert os.path.exists(join(work_path, '.git'))
         yield work_path
Esempio n. 14
0
 def setUp(self):
     TestCase.setUp(self)
     _, self.proj1, _, self.proj1_fork = setup_repos(
         mkdtemp(), 'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(
         mkdtemp(), 'testproject2')
Esempio n. 15
0
 def setUp(self):
     TestCase.setUp(self)
     _, self.proj1, _, self.proj1_fork = setup_repos(
         mkdtemp(), 'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(
         mkdtemp(), 'testproject2')